public
partial
class
Form1 : Form
{
System.Windows.Forms.Timer timer =
new
System.Windows.Forms.Timer() { Interval = 200};
List<PointF> points =
new
List<PointF>();
public
Form1()
{
InitializeComponent();
this
.DoubleBuffered =
true
;
this
.timer.Tick += (o, e) =>
this
.Invalidate();
this
.timer.Start();
}
protected
override
void
OnPaint(PaintEventArgs e)
{
if
(points.Count < 100)
{
int
t = points.Count + 1;
float
x = t * (
float
)Math.Cos(t / 5f);
float
y = t * (
float
)Math.Sin(t / 5f);
PointF p =
new
PointF(
this
.ClientRectangle.Width / 2 + x,
this
.ClientRectangle.Height / 2 + y);
points.Add(p);
}
if
(points.Count > 2)
{
e.Graphics.DrawCurve(Pens.Blue, points.ToArray());
}
}
}
上楼是螺线,如果是‘圆的渐开线’,则公式为(http://zh./wiki/%E6%BC%B8%E4%BC%B8%E7%B7%9A):
x = cos(t) + t * sin(t);y = sin(t) - t * cos(t);