Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i fixed that code to this one
 public partial class frmFlow : Form
    {
        string FineString = " ";
        PointF thispoint;
        Font thisFont = new Font("Times New Roman", 100);
        SolidBrush thisbrush = new SolidBrush(Color.Red);

        public frmFlow()
        {
            InitializeComponent();
        }

        private void frmFlow_Load(object sender, EventArgs e)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true); 
            timer1.Start();
        }

        SizeF size = new SizeF();
        RectangleF rc = new RectangleF();
        private void timer1_Tick(object sender, EventArgs e)
        {
            FineString = "(-: Smile :-)";
            timer1.Interval = 33; //(int)nudSpeed.Value; ;
            Invalidate();
        }
        protected PointF getPoint()
        {
            thispoint.X -= 5;//(int)nudDistance.Value; 
            if (thispoint.X <= 0 - size.Width)
            {
                thispoint.X = this.Width;
            }
            thispoint.Y = 180;
            return thispoint;
        }

        private void frmFlow_Paint(object sender, PaintEventArgs e)
        {
            size = e.Graphics.MeasureString(FineString, thisFont);
             e.Graphics.DrawString(FineString, thisFont, thisbrush, getPoint());
        }
}

it's very well but how can i speed it up that it will not look like jumping so i want to know what to speed up the interval of the timer or to decrease the X point in getpoint or something else
please if you can write a code to do
thank
Posted
Updated 17-Jan-10 4:05am
v6

1 solution

Check how much time has elapsed since the last draw operation. Calculate the distance to travel based on that duration. This will produce smoother animation.

Also, you can draw a faded trail. That might make it appear as if the image is being viewed more closely to real life, where light comes into the eye over time, rather than instantly at a specified interval. For example, try waving your hand in front of your face, but keep your eyes fixed on an object further from you than your hand (say, your computer screen). You'll notice that the faster you move your hand, the blurrier it looks. If you move your hand back and forth really fast, it looks like one big blur. Simulate this when drawing text by drawing the faded text near the old position, then a more opaque version of the text nearer to the new position, then finally a fully opaque version of the text nearer to the new position (you can draw as many faded versions as you like). There are probably nuances you want to consider too. For example, you may not want to draw a fully opaque string. You may want to make it more transparent the faster the text is moving to more closely simulate how vision works in real life. Or if there is no acceleration, then maybe you want to draw each part of the trail with the same level of opaqueness, rather than increasing opaqueness.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900