Packagepegas.draw
Classpublic dynamic class StarPen
InheritanceStarPen Inheritance Pen Inheritance flash.utils.Proxy

This pen drawing a star shaped polygons. This pen draw stars in either direction for creating knockouts.

Example :

     import pegas.draw.Align ;
     import pegas.draw.StarPen ;
     import pegas.draw.FillStyle ;
     
     stage.scaleMode = StageScaleMode.NO_SCALE ;
     stage.align = "" ;
     
     var shape:Shape = new Shape() ;
     shape.x = 740 / 2 ;
     shape.y = 420 / 2 ;
     
     var pen:StarPen = new StarPen( shape.graphics ) ;
     pen.align = Align.CENTER ;
     pen.fill  = new FillStyle( 0xEBD936 , 0.6 ) ;
     pen.draw() ;
     
     addChild( shape ) ;
     
     var keyDown:Function = function( e:KeyboardEvent ):void
     {
         var code:uint = e.keyCode ;
         switch( code )
         {
             case Keyboard.LEFT :
             {
                 pen.draw( 0, 0, 5, 40, 60 , 0,  Align.LEFT ) ;
                     break ;
             }
             case Keyboard.RIGHT :
             {
                 pen.draw( 0, 0, 5, 80, 40 , 0,  Align.RIGHT ) ;
                 break ;
             }
             case Keyboard.UP :
             {
                 pen.draw( 0, 0, 20, 100, 40 , 0 , Align.TOP ) ;
                 break ;
             }
             case Keyboard.DOWN :
             {
                 pen.draw( 0, 0, 10 , 100, 60 , 0, Align.BOTTOM ) ;
                 break ;
             }
             case Keyboard.SPACE :
             {
                 pen.x = 10 ;
                 pen.y = 40 ;
                 pen.points  = 8  ;
                 pen.innerRadius = 100 ;
                 pen.outerRadius = 50 ;
                 pen.angle  = 40 ;
                 pen.align  = Align.TOP_RIGHT ;
                 pen.draw() ;
                 break ;
             }
        }
     }
     
     var enterFrame:Function = function( e:Event ):void
     {
         pen.angle += 10 ;
         pen.draw() ;
     }
     
     var mouseDown:Function = function( e:MouseEvent ):void
     {
         stage.addEventListener( Event.ENTER_FRAME , enterFrame ) ;
     }
     
     var mouseUp:Function = function( e:MouseEvent ):void
     {
         stage.removeEventListener( Event.ENTER_FRAME , enterFrame ) ;
     }
     
     stage.addEventListener( MouseEvent.MOUSE_DOWN , mouseDown ) ;
     stage.addEventListener( MouseEvent.MOUSE_UP , mouseUp ) ;
     stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
     



Public Properties
 PropertyDefined by
 Inheritedalign : uint
(read-write) Determinates the align value of the pen.
Pen
  angle : Number = 0
Starting angle in degrees (default to 0).
StarPen
 Inheritedfill : IFillStyle
Determinates the fill style object of the pen.
Pen
 Inheritedgraphics : Graphics
Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur.
Pen
  innerRadius : Number
The radius of the indent of the points
StarPen
 Inheritedline : ILineStyle
Determinates the line style object of the pen.
Pen
  outerRadius : Number
The radius of the tips of the points
StarPen
  points : uint
The number of points of the star.
StarPen
 InheriteduseClear : Boolean = true
Indicates if the clear() method is invoked at the end of the draw method.
Pen
 InheriteduseEndFill : Boolean = true
Indicates if the endFill() method is invoked at the end of the draw method.
Pen
  x : Number
The offset x value of the center of the circle.
StarPen
  y : Number
The offset y value of the center of the circle.
StarPen
Public Methods
 MethodDefined by
  
StarPen(graphic:*, x:Number = 0, y:Number = 0, points:uint = 5, innerRadius:Number = 20, outerRadius:Number = 40, angle:Number = 20, align:uint = 10)
Creates a new StarPen instance.
StarPen
 Inherited
BF(... arguments):void
Defines a shortcut reference to used the beginBitmapFill method.
Pen
 Inherited
C(... arguments):void
Defines a shortcut reference to used the curveTo method.
Pen
 Inherited
CL():void
Defines a shortcut reference to used the clear method.
Pen
  
draw(... arguments):void
Draws the shape.
StarPen
  
drawShape():void
This method contains the basic drawing shape algorithm.
StarPen
 Inherited
EF():void
Defines a shortcut reference to used the endFill method.
Pen
 Inherited
F(... arguments):void
Defines a shortcut reference to used the beginFill method.
Pen
 Inherited
GF(... arguments):void
Defines a shortcut reference to used the beginGradientFill method.
Pen
 Inherited
GS(... arguments):void
Defines a shortcut reference to used the lineGradientStyle method.
Pen
 Inherited
L(... arguments):void
Defines a shortcut reference to used the lineTo method.
Pen
 Inherited
M(... arguments):void
Defines a shortcut reference to used the moveTo method.
Pen
 Inherited
S(... arguments):void
Defines a shortcut reference to used the lineStyle method.
Pen
  
setPen(... arguments):void
Sets the shape options to defined all values to draw the shape.
StarPen
 Inherited
toString():String
Returns the string representation of this object.
Pen
Protected Methods
 MethodDefined by
 Inherited
callProperty(methodName:*, ... rest):*
Overrides the behavior of an object property that can be called as a function.
Pen
Property detail
angleproperty
public var angle:Number = 0

Starting angle in degrees (default to 0).

innerRadiusproperty 
public var innerRadius:Number

The radius of the indent of the points

outerRadiusproperty 
public var outerRadius:Number

The radius of the tips of the points

pointsproperty 
points:uint  [read-write]

The number of points of the star. This value is always > 2.

Implementation
    public function get points():uint
    public function set points(value:uint):void
xproperty 
public var x:Number

The offset x value of the center of the circle.

yproperty 
public var y:Number

The offset y value of the center of the circle.

Constructor detail
StarPen()constructor
public function StarPen(graphic:*, x:Number = 0, y:Number = 0, points:uint = 5, innerRadius:Number = 20, outerRadius:Number = 40, angle:Number = 20, align:uint = 10)

Creates a new StarPen instance.

Parameters
graphic:* — The Graphics reference to control with this helper. You can passed-in a Shape or Sprite/MovieClip reference in argument.
 
x:Number (default = 0) — (optional) The x location of the center of the circle relative to the registration point of the parent display object (in pixels).
 
y:Number (default = 0) — (optional) The y location of the center of the circle relative to the registration point of the parent display object (in pixels).
 
points:uint (default = 5) — (optional) The number of points (Math.abs(sides) must be > 2)
 
innerRadius:Number (default = 20) — (optional) The radius of the indent of the points.
 
outerRadius:Number (default = 40) — (optional) The radius of the tips of the points.
 
angle:Number (default = 20) — (optional) The starting angle in degrees. (defaults to 0)
 
align:uint (default = 10) — (optional) The Align value to align the shape.
Method detail
draw()method
public override function draw(... arguments):void

Draws the shape.

Parameters
... arguments — (optional)The x location of the center of the circle relative to the registration point of the parent display object (in pixels).
drawShape()method 
public override function drawShape():void

This method contains the basic drawing shape algorithm.

setPen()method 
public function setPen(... arguments):void

Sets the shape options to defined all values to draw the shape.

Parameters
... arguments — (optional) The x location of the center of the circle relative to the registration point of the parent display object (in pixels).