C#里 鼠标拖拽画出一个五角星怎么实现?
展开全部
protected override void OnPaint(PaintEventArgs args)
{
Graphics grfx = args.Grphics;
int cx = 300;
int cy = 160;
Point[] apt = new Point[5];
for (int i = 0; i< apt.Length; i++)
{
double dAngle = (i * 0.8 - 0.5) * Math.PI;
apt[i] = new Point((int)(cx * (0.25 + 0.24 * Math.Cos(dAgngle))),(int)(cy * (0.5 + 0.48 * Math.Sin(dAngle))));
}
grfx.FillPolygon(new SolidBrush(Color.Red),
apt,
FillMode.Winding);
}
{
Graphics grfx = args.Grphics;
int cx = 300;
int cy = 160;
Point[] apt = new Point[5];
for (int i = 0; i< apt.Length; i++)
{
double dAngle = (i * 0.8 - 0.5) * Math.PI;
apt[i] = new Point((int)(cx * (0.25 + 0.24 * Math.Cos(dAgngle))),(int)(cy * (0.5 + 0.48 * Math.Sin(dAngle))));
}
grfx.FillPolygon(new SolidBrush(Color.Red),
apt,
FillMode.Winding);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询