 GDI+ Shapes: Arcs

 Introduction
 An arc is a portion or segment of an ellipse, meaning an arc is a non-complete ellipse. While a pie is a closed shape, an arc is not: it uses only a portion of the line that defines an ellipse. Because an arc must confirm to the shape of an ellipse, it is defined as it fits in a rectangle and can be illustrated as follows: To support arcs, the Graphics class is equipped with the DrawArc() method that is provided in four versions whose syntaxes are:

public void DrawArc(Pen pen,
Rectangle rect,
float startAngle, float sweepAngle);
public void DrawArc(Pen pen,
RectangleF rect,
float startAngle, float sweepAngle);
public void DrawArc(Pen pen,
int x, int y, int width, int height,
int startAngle, int sweepAngle);
public void DrawArc(Pen pen,
float x, float y, float width, float height,
float startAngle, float sweepAngle);

The ellipse that would contain the arc must be drawn in a Rectangle or a RectangleF rect. You can also define that ellipse by the coordinates of its inscribed rectangle x, y, and its dimensions width, height.  Besides the borders of the rectangle in which the arc would fit, an arc must specify its starting angle, startAngle, measured clockwise from the x-axis its starting point. An arc must also determine its sweep angle measured clockwise from the startAngle parameter to the end of the arc. These two value follow the same definitions we reviewed for the Graphics.Pie() method.

Here is an example:

private void Exercise_Paint(object sender, PaintEventArgs e)
{
Pen penCurrent = new Pen(Color.Red);
e.Graphics.DrawArc(penCurrent, 20, 20, 200, 150, 225, 200);
} 