短视频开发,实现窗体抖动

2020-12-31 16:32:29 浏览数 (1)

短视频开发,实现窗体抖动相关的代码

代码语言:javascript复制
public class Shake
{
    /// <summary>
    /// 震动方法
    /// </summary>
    /// <param name="form">窗体</param>
    public void Vibration(Form form)
    {
        Point pOld = form.Location;//原来的位置
        int radius = 3;//半径
        for (int n = 0; n < 3; n  ) //旋转圈数
        {
            //右半圆逆时针
            for (int i = -radius; i <= radius; i  )
            {
                 int x = Convert.ToInt32(Math.Sqrt(radius * radius - i * i));
                 int y = -i;
                 form.Location = new Point(pOld.X   x, pOld.Y   y);
                    Thread.Sleep(10);
            }
            //左半圆逆时针
            for (int j = radius; j >= -radius; j--)
            {
                 int x = -Convert.ToInt32(Math.Sqrt(radius * radius - j * j));
                 int y = -j;
                 form.Location = new Point(pOld.X   x, pOld.Y   y);
                 Thread.Sleep(10);
            }
        }
        //抖动完成,恢复原来位置
        form.Location = pOld;
    }
}

以上就是 短视频开发,实现窗体抖动相关的代码,更多内容欢迎关注之后的文章

0 人点赞