我正在尝试编写一个Windows应用程序,显示一个由七个不等份组成的饼图(分别为25%,20%,18%,17%,10%,10%,10%),每个部分都会有不同的颜色。
目前为止,我已经创建了带有颜色的笔和画刷,并绘制了一个圆形。
这是我目前为止的代码:
private void Form1_Paint(object sender, PaintEventArgs e)
{
this.BackColor = Color.White;
this.Text = "Pie Chart";
this.Width = 350;
this.Height = 350;
Pen black = new Pen(Color.Black);
Pen blue = new Pen(Color.Blue);
Pen green = new Pen(Color.Green);
Pen red = new Pen(Color.Red);
Pen orange = new Pen(Color.Orange);
Pen pink = new Pen(Color.Pink);
Pen purple = new Pen(Color.Purple);
Pen magenta = new Pen(Color.Purple);
Brush brBlue = blue.Brush;
Brush brGreen = green.Brush;
Brush brRed = red.Brush;
Brush brOrange = orange.Brush;
Brush brPink = pink.Brush;
Brush brPurple = purple.Brush;
Brush brMagenta = magenta.Brush;
Graphics g = e.Graphics;
g.DrawEllipse(black, 20, 10, 300, 300);
}
我的问题是,绘制饼图楔形部分的最简单方法是什么?