现在我想让圆沿着多边形的边。有人可以帮我吗?
代码
namespace polygon
{
public partial class Form1 : Form
{
int x, y;
Pen p1 = new Pen(Color.DarkBlue, 5);
PointF[] puncte = new PointF[4];
public Form1()
{
InitializeComponent();
x = 100;
y = 100;
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
puncte[0] = new PointF(100, 100);
puncte[1] = new PointF(320, 100);
puncte[2] = new PointF(380, 320);
puncte[3] = new PointF(100, 320);
e.Graphics.DrawPolygon(p1, puncte);
e.Graphics.FillEllipse(Brushes.Red, x, y, 40, 40);
}
public void timer1_Tick(object sender, EventArgs e)
{
if (x < 300 && y == 80)
x = x + 20;
else
if (y < 300 && x == 300)
y = y + 20;
else
if (y == 300 && x > 80)
x = x - 20;
else
y = y - 20;
Invalidate();
}
}
}