Previous Page
Next Page

Recipe 7.11. Drawing a Star

Problem

You want to draw a star.

Solution

Use the Pen.drawStar( ) method.

Discussion

The Pen.drawStar( ) method enables you to quickly draw a star shape programmatically. The method accepts the following parameters:



x

The x coordinate of the center of the star.



y

The y coordinate of the center of the star.



points

The number of points on the star.



innerRadius

The radius of the inner part of the star.



outerRadius

The radius of the outer part of the star.



rotation

The default value is 0; you can specify a rotation in degrees.

The following example draws a five-pointed star:

var pen:Pen = new Pen(sampleSprite.graphics);
pen.drawStar(100, 100, 5, 50, 100);


Previous Page
Next Page
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)