GDI+绘制如下效果:
代码展示:
class Circular
{
private Graphics g = null;
public Circular(Graphics gg)//重写
{
g = gg;
}
public void Draw(int x1, int y1, int x2, int y2)
{
if (g != null)
{
g.DrawPie(new Pen(Color.Blue,2), 150, 150, 300, 300, -30, -120);
//两个扇形的x->width,y->height一一对应,x减少1/3,对应width就需要增加1/3(y与height相同规律)
g.FillPie(new SolidBrush(Color.Green), 150, 150, 300, 300, -30, -120);
g.FillPie(new SolidBrush(Color.Yellow), 200, 200, 200, 200, -30, -120);
}
}
}
private void btnCir_Click(object sender, EventArgs e)
{
Circular myGDI = new Circular(this.CreateGraphics());
myGDI.Draw(0,0,100,100);
}