Recipe 7.5. Drawing an
Arc
Problem
You want to draw an arc.
Solution
Use the Pen.drawArc( ) method.
Discussion
An arc is a part of the outline from a circle.
Drawing an arc with the curveTo( ) method is rather
difficult for various reasons. However, by using the
Pen.drawArc( ) method, you can quickly draw an arc of any
radius and length. The drawArc( ) method accepts the
following parameters:
x
-
The x
coordinate of the arc center (the center of the circle).
y
-
The y
coordinate of the arc center.
radius
-
The radius of the arc.
arc
-
The angle measurement of the arc, specified in
degrees.
startingAngle
-
The starting angle of the arc. The default value
is 0.
radialLines
-
A Boolean value that indicates whether to draw
the radial lines that connect the arc to the center. The default is
false. When set to true, the arc looks like a
slice.
The following draws an arc with radial lines;
the radius is 50, the arc angle is 80 degrees, and the starting
angle is 20 degrees:
var pen:Pen = new Pen(graphics);
pen.drawArc(100, 100, 50, 80, 20, true);
|