我正在尝试使用线性插值移动光标。我的问题是,y0 + (y1 - y0) * ((x - x0) / (x1 - x0))
尽管 x 发生了变化,但从不改变的值。我无法弄清楚我错过了什么。
public void MoveCursor(int x1, int y1)
{
int y, y0, x, x0;
y0 = Cursor.Position.Y;
x0 = Cursor.Position.X;
for (x = x0; x > x1; x--)
{
y = y0 + (y1 - y0) * ((x - x0) / (x1 - x0));
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(x,y);
Cursor.Clip = new Rectangle(this.Location, this.Size);
Console.Out.WriteLine("X:{0} Y:{1}", x, y);
System.Threading.Thread.Sleep(100);
}
}