Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Explaining DrawArc method?

Tags:

c#

winforms

draw

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:

enter image description here

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.

like image 888
ykh Avatar asked Mar 16 '13 10:03

ykh


People also ask

What is the use of DrawArc () method in Java?

drawArc. Draws the outline of a circular or elliptical arc covering the specified rectangle. The resulting arc begins at startAngle and extends for arcAngle degrees, using the current color.

How many parameters has the DrawArc method?

The DrawArc method takes 4 parameters: 1-The pen. 2-Rectangle to draw in. 3-Start angle. 4-Sweep angle.

Which method draws an ellipse starting angle and ending angle?

Using the 3-point ellipse tool, you can draw an ellipse by first drawing its centerline and then drawing its height. This method lets you draw ellipses at an angle.

What is sweep angle in arc?

sweep angle = 90 degrees. In the above diagram, shaded portion is the rendered arc portion.As you can see, It starts from 0 degrees as depicted in the coordinate system, and it sweeps 90 degrees in clockwise direction. Case 2: startAngle = 90 degrees. sweep angle = 180 degrees.


1 Answers

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;
        } 
like image 112
Ali Sarshogh Avatar answered Sep 28 '22 08:09

Ali Sarshogh