Graphics.DrawArc explanation requested

  • Thread starter Christopher Ireland
  • Start date


Christopher Ireland


The following simple code can be used to see the behaviour which I would
like to understand a little further:

public partial class Form1 : Form
public Form1()

protected override void OnPaint(PaintEventArgs e)

int start = 0, sweep = 135;

Rectangle rect = e.ClipRectangle;
rect.Inflate(-50, -50);

if(rect.Height > 0 && rect.Width > 0)
e.Graphics.DrawArc(Pens.Red, rect, start, sweep);

protected override void OnResize(EventArgs e)

If you now resize the form you will see how the end point of the arc seems
to change position; resizing horizontally will give you an arc which appears
to trace nearly 180º. Changing the value "sweep" to 90º does not produce the
same effect, however.

Can anybody please help me by shedding a little light on this behaviour?




It has to do with the fact that the left and right are so close together. If
you draw a line from the center point horizontally to the left and then
another line from the center point to the top left of your arc, you would
find the angle to be roughly 45 degrees (within the range of error a few
pixels provides). The problem is, your center is now only a couple pixels
from the left side, hence it appears to be almost 180 degrees, but it's not
180 degreee from the center. It's just very close to 180 degrees from the
right side.


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question