Reputation: 1835
I have a task in which I have to draw a Figure of Eight, so I thought of it as drawing four arcs. I tried using the DrawArc
method but I really don't understand how does it work at all.
The DrawArc
method takes 4 parameters:
1-The pen.
2-Rectangle to draw in.
3-Start angle.
4-Sweep angle.
What I don't get is the start and sweep angle, could anybody with knowledge tell me what are these 2 parameters and how do they effect the drawing ?
Also does giving the rectangle parameter takes the (0,0) as starting point.
Edit:
I have tried the following code:
e.Graphics.DrawArc(drawPen, 0, 0, 600, 400, 45, 90);
e.Graphics.DrawArc(drawPen, 0, 345, 600, 400, -45, -90);
which resulted in the following:
I would like to make it larger, I have played with the code but not success, I didn't understand what I am doing, I was just changing numbers, that is why I asked for an explanation.
Upvotes: 7
Views: 13547
Reputation: 566
For anyone else who lands here, trying to figure out what "Angle in degrees measured clockwise from the x-axis to the starting point of the arc" or "Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc" are actually supposed to mean, this link explains it well with diagrams.
A picture speaks a thousand words, Microsoft.
Without a diagram, this might be useful:
Your arc is part of an ellipse that fits exactly into the rectangle you are supplying to the method. The startAngle and sweepAngle define where to start drawing on that ellipse and how far (in degrees) to keep drawing for. If you draw an imaginary line from the centre of the ellipse horizontally to the right, the startAngle is the angle between that line and the angle you want to start drawing at. The sweepAngle is the angle subtended by the drawn portion of the ellipse. Note that +ve is clockwise.
Examples:
to draw from the 6 o'clock position to the 9 o'clock, i.e. the bottom-left quarter of the ellipse, StartAngle=90 and sweepAngle=90. to draw
from the 6 o'clock position to the 12 o'clock, i.e. the left-half of the ellipse, StartAngle=90 and sweepAngle=180.
Upvotes: 0
Reputation: 31
The coordinates are for drawing a complete ellipse from the top and left by width and height. Which part of the ellipse is actually drawn is determined by start and end angles. If the circle is a clock, then 3:00 is 0, 6:00 is 90, 9:00 is 180 and 12:00 is 270.
Upvotes: 3
Reputation: 2197
you imagine 2-D Coordinate axes and clockwise rotation ,
Start angle : shows the point where you want to start drawing from X axes
Sweep angle : measure of clockwise rotation ,
also MSDN Said:
startAngle: Angle in degrees measured clockwise from the x-axis to the starting point of the arc.
sweepAngle: Angle in degrees measured clockwise from the startAngle parameter to ending point of the arc.
for example : Horizantal Arc and Vertical Arc :
switch (ArcType)
{
case ArcType.Horizantal :
g.DrawArc(Pens.Black, 0, 15, 15, 15, 0, -180);
break;
case ArcType.Vertical:
g.DrawArc(Pens.Black, 0, 15, 15,15, -90,180);
break;
}
Upvotes: 3