速度流出串 [英] speed outflow string

查看:130
本文介绍了速度流出串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将该代码固定为该代码

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());
        }
}


它很好,但是我如何加快它的速度,使其看起来不像跳跃,所以我想知道如何加快计时器的间隔或减少getpoint或其他方面的X点
如果可以编写代码,请
感谢


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

推荐答案

检查自上次绘制操作以来已花费了多少时间.根据该持续时间计算旅行距离.这样会产生更流畅的动画.

此外,您可以绘制褪色的轨迹.这可能会使图像看起来更接近现实生活,即随着时间的流逝而不是按指定的间隔立即进入眼睛.例如,尝试将手在脸前挥动,但将眼睛固定在比手更远的物体上(例如,计算机屏幕).您会注意到,您的手移动得越快,它看起来就越模糊.如果您非常快地前后移动手,看起来就像是一大模糊.在绘制文本时模拟此过程,方法是在旧位置附近绘制褪色的文本,然后在更接近新位置的位置绘制文本的不透明版本,然后在更接近新位置的位置绘制文本的完全不透明的版本(您可以绘制尽可能多的褪色文本)版本).您可能还需要考虑细微差别.例如,您可能不想绘制完全不透明的字符串.您可能希望使文本移动得越快,使其更加透明,从而更紧密地模拟视觉在现实生活中的工作方式.或者,如果没有加速度,则可能要以相同的不透明度级别绘制轨迹的每个部分,而不是增加不透明度.
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.


这篇关于速度流出串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆