Filling an Area in visual studio C#
- by lajoo
I'm drawing a circle in C# and i have divided it into some parts,i want to fill different parts with different colors,is there anyway to do this? and how?i tried using fillpie() but i couldn't get the arguments to work.
here is the code:
int r = 150;
g.DrawEllipse(Pens.Black, 300 - r, 250 - r, 2 * r, 2 * r);
if (p != 0)
g.DrawLine(Pens.Black, 300, 250, 300 + r, 250);
double sum;
sum = 0.0;
for (int j = 0; j < p; j++)
sum += data[j].value;
double angle;
angle = 0.0;
for (int i = 0; i < p; i++)
{
angle += (double)(data[i].value / sum) * 2.0 * Math.PI;
textBox1.Text += sum.ToString() + " : " + angle.ToString() + ":" + Math.Cos(angle).ToString() + "\r\n";
g.DrawLine(Pens.Black, 300, 250, 300 + (int)(Math.Cos(angle) * r), 250 - (int)(Math.Sin(angle) * r));
//g.FillPie(Brushes.Black, 300-r , 250 - r, r, r ,(float)(angle),(float)(angle+ (data[i].value / sum) * 2.0 * Math.PI));
}
this actually divides the circle into different parts,i don't know how to fill them
the commented line is where i