Bitmap cBmp = new Bitmap(width,height); //创建画布宽度为471,高度为367的Bitmap实例
Graphics cGraphic;
Color[] cColor = { Color.Red, Color.Blue, Color.Green, Color.Gray, Color.LightCoral, Color.Gold };
Pen cPen;
SolidBrush cSolidBrush;
Point[] cPoints;
int RowNum = 6;
int i = 0;
int j = 0;
int cAngle = 0;
int tmp = 0;
//定义圆心坐标
int xCircleCenter = 100;
int yCircleCenter = 100;
cGraphic = Graphics.FromImage(cBmp);
cGraphic.Clear(Color.Snow); //用白色清屏 Snow
string temp="";
for (j = 0; j < RowNum; j++)
{
cAngle = 60;//(int)(60 / TotalValue) * 360; //度数 (int)ds.Tables[0].Rows[j][0]
//cPoints = new Point[cAngle+1];
cPoints = new Point[cAngle+1];
//用数学公式画圆
cPen = new Pen(cColor[j], 3);
cSolidBrush = new SolidBrush(cColor[j]);
for (i = tmp; i <= (tmp + cAngle); i++)
{
double t = i;
cPoints[i - tmp] = new Point();
cPoints[i - tmp].X = (int)((1-System.Math.Sin(t / 180 * System.Math.PI)) * (80));
cPoints[i - tmp].Y = (int)((1-System.Math.Cos(t / 180 * System.Math.PI)) * (80));
temp += "(" + cPoints[i-tmp].X.ToString() + "," + cPoints[i - tmp].Y.ToString() + ")/n";
}
cGraphic.DrawString(temp, new Font("Tahoma", 8, FontStyle.Regular), new SolidBrush(Color.Black), new RectangleF(5, 5, 200, 200));
//加入圆心坐标点
cPoints[cAngle] = new Point();
cPoints[cAngle].X = xCircleCenter - 20;
cPoints[cAngle].Y = xCircleCenter - 20;
//画扇区对应的三角形
cPen = new Pen(cColor[j], 3);
cGraphic.DrawPolygon(cPen, cPoints);
cSolidBrush = new SolidBrush(cColor[j]);
cGraphic.FillPolygon(cSolidBrush, cPoints);
tmp = tmp + cAngle;
}
return cBmp;