public void AddPie(float x, float y, float width, float height, float startAngle, float sweepAngle)
{
float sin_alpha, cos_alpha;
float rx = width / 2;
float ry = height / 2;
/* center */
float cx = x + rx;
float cy = y + ry;
/* angles in radians */
float alpha = (float)(startAngle * Math.PI / 180);
/* adjust angle for ellipses */
alpha = (float) Math.Atan2 (rx * Math.Sin (alpha), ry * Math.Cos (alpha));
sin_alpha = (float)Math.Sin (alpha);
cos_alpha = (float)Math.Cos (alpha);
/* move to center */
Append (cx, cy, PathPointType.Start, false);
/* draw pie edge */
if (Math.Abs (sweepAngle) < 360)
Append (cx + rx * cos_alpha, cy + ry * sin_alpha, PathPointType.Line, false);
/* draw the arcs */
AppendArcs (x, y, width, height, startAngle, sweepAngle);
/* draw pie edge */
if (Math.Abs (sweepAngle) < 360)
Append (cx, cy, PathPointType.Line, false);
CloseFigure ();
}