我来举个例子给你
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
bool b = true;
static int m =0, n = 80;
private void Form1_Paint(object sender, PaintEventArgs e)
{
if (b)
{
int x = 240, y = 120, k=0,d = 100, x1, y1;
Point[] a = new Point[18];
Graphics g = this.CreateGraphics();
Pen p = new Pen(Color.Red, 1);
p.DashStyle = DashStyle.Solid;
for (int i = 0; i < 18; i++)
{
x1 = x + Convert.ToInt32(d * Math.Cos(3.14 * i / 9));
y1 = y + Convert.ToInt32(d * Math.Sin(3.14 * i / 9));
a[i] = new Point(x1, y1);
}
for (int i = 0; i < 18; i++)
for (int j = i; j < 18; j++)
{
k++;
p.Color = Color.FromArgb(k+3, m, k+n);
g.DrawLine(p, a[i], a[j]);
}
}
这个是画一个18边形,没两点都连接的图来的,其中就用到了坐标数组,慢慢看,不懂再问···
温馨提示:答案为网友推荐,仅供参考