Packagegraphics.drawing
Classpublic dynamic class TrianglePen
InheritanceTrianglePen Inheritance Pen Inheritance flash.utils.Proxy

Draw a triangle with the A, B and C points in the 2D space. ab and ac are the lengths to defines the base of the shape.

Example :

     package examples 
     {
         import graphics.Align;
         import graphics.FillStyle;
         import graphics.LineStyle;
         
         import graphics.drawing.RectanglePen;
         import graphics.drawing.TrianglePen;
         
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.events.KeyboardEvent;
         import flash.ui.Keyboard;
         
         public class ExampleTrianglePen extends Sprite 
         {
             public function ExampleTrianglePen()
             {
                 var container:Sprite = new Sprite() ;
                 
                 container.x = 740/2 ;
                 container.y = 200   ;
                 
                 addChild( container ) ;
                 
                 ///////////////////////////////
                 
                 a = new Shape() ;
                 b = new Shape() ;
                 c = new Shape() ;
                 
                 var rec:RectanglePen ;
                 
                 rec = new RectanglePen( a ) ;
                 rec.fill  = new FillStyle( 0xFFFFFF ) ;
                 rec.draw( 0 , 0 , 5 , 5 , Align.CENTER ) ;
                 
                 rec = new RectanglePen( b ) ;
                 rec.fill  = new FillStyle( 0xFFFFFF ) ;
                 rec.draw( 0 , 0 , 5 , 5 , Align.CENTER ) ;
                 
                 rec = new RectanglePen( c ) ;
                 rec.fill  = new FillStyle( 0xFFFFFF ) ;
                 rec.draw( 0 , 0 , 5 , 5 , Align.CENTER ) ;
                 
                 ///////////////////////////////
                 
                 var canvas:Shape = new Shape() ;
                 
                 container.addChild( canvas ) ;
                 container.addChild( a ) ;
                 container.addChild( b ) ;
                 container.addChild( c ) ;
                 
                 pen       = new TrianglePen( canvas.graphics, 200, 200, 90, 90, 0, 0) ;
                 pen.fill  = new FillStyle( 0x3F65FC , 0.6 ) ;
                 pen.line  = new LineStyle( 2, 0xFFFFFF ) ;
                 
                 pen.draw() ;
                 
                 update() ;
                 
                 stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
             }
             
             public var a:Shape ;
             public var b:Shape ;
             public var c:Shape ;
             
             public var pen:TrianglePen ;
             
             public function keyDown( e:KeyboardEvent ):void
             {
                 var code:uint = e.keyCode ;
                 switch( code )
                 {
                     case Keyboard.LEFT :
                     {
                         pen.rotation -= 10 ;
                         pen.draw() ;
                         break ;
                     }
                     case Keyboard.RIGHT :
                     {
                         pen.rotation += 10 ;
                         pen.draw() ;
                         break ;
                     }
                     case Keyboard.UP :
                     {
                         pen.angle -= 10 ;
                         pen.draw() ;
                         break ;
                     }
                     case Keyboard.DOWN :
                     {
                         pen.angle += 10 ;
                         pen.draw() ;
                         break ;
                     }
                 }
                 trace( "angle : " + pen.angle + " rotation:" + pen.rotation ) ;
                 update() ;
             }
             
             public function update():void
             {
                 a.x = pen.a.x ;
                 a.y = pen.a.y ;
                 
                 b.x = pen.b.x ;
                 b.y = pen.b.y ; 
                 
                 c.x = pen.c.x ;
                 c.y = pen.c.y ; 
             }
         }
     }
     



Public Properties
 PropertyDefined By
  a : Point
[read-only] Indicates the A corner position of the triangle.
TrianglePen
  ab : Number
Indicates the AB distance of the triangle.
TrianglePen
  ac : Number
Indicates the AC distance of the triangle.
TrianglePen
 Inheritedalign : uint
Determinates the align value of the pen.
Pen
  angle : Number
Indicates the value of the angle used to draw the shape.
TrianglePen
  b : Point
[read-only] Indicates the B corner position of the triangle.
TrianglePen
  barycenter : Point
[read-only] Indicates a new barycenter Point object of the triangle.
TrianglePen
  c : Point
[read-only] Indicates the C corner position of the triangle.
TrianglePen
 Inheritedfill : IFillStyle
Determinates the fill style object of the pen.
Pen
 Inheritedgraphics : *
Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur.
Pen
 Inheritedline : ILineStyle
Determinates the line style object of the pen.
Pen
  rotation : Number
Indicates the rotation value of the shape.
TrianglePen
 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
Defines the x barycentre position of the triangle shape.
TrianglePen
  y : Number
Defines the y barycentre position of the triangle shape.
TrianglePen
Public Methods
 MethodDefined By
  
TrianglePen(graphic:*, ab:Number = 0, ac:Number = 0, angle:Number = 360, rotation:Number = 0, x:Number = 0, y:Number = 0)
Creates a new TrianglePen instance.
TrianglePen
 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
[override] Draws the shape.
TrianglePen
  
drawShape():void
[override] This method contains the basic drawing shape algorithm.
TrianglePen
 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.
TrianglePen
Property Detail
aproperty
a:Point  [read-only]

Indicates the A corner position of the triangle.


Implementation
    public function get a():Point
abproperty 
ab:Number

Indicates the AB distance of the triangle.


Implementation
    public function get ab():Number
    public function set ab(value:Number):void
acproperty 
ac:Number

Indicates the AC distance of the triangle.


Implementation
    public function get ac():Number
    public function set ac(value:Number):void
angleproperty 
angle:Number

Indicates the value of the angle used to draw the shape.


Implementation
    public function get angle():Number
    public function set angle(value:Number):void
bproperty 
b:Point  [read-only]

Indicates the B corner position of the triangle.


Implementation
    public function get b():Point
barycenterproperty 
barycenter:Point  [read-only]

Indicates a new barycenter Point object of the triangle.


Implementation
    public function get barycenter():Point
cproperty 
c:Point  [read-only]

Indicates the C corner position of the triangle.


Implementation
    public function get c():Point
rotationproperty 
rotation:Number

Indicates the rotation value of the shape.


Implementation
    public function get rotation():Number
    public function set rotation(value:Number):void
xproperty 
x:Number

Defines the x barycentre position of the triangle shape.


Implementation
    public function get x():Number
    public function set x(value:Number):void
yproperty 
y:Number

Defines the y barycentre position of the triangle shape.


Implementation
    public function get y():Number
    public function set y(value:Number):void
Constructor Detail
TrianglePen()Constructor
public function TrianglePen(graphic:*, ab:Number = 0, ac:Number = 0, angle:Number = 360, rotation:Number = 0, x:Number = 0, y:Number = 0)

Creates a new TrianglePen instance.

Parameters
graphic:* — The Graphics reference to control with this helper. You can passed-in a Shape or Sprite/MovieClip reference in argument.
 
ab:Number (default = 0) — The AB distance of the triangle.
 
ac:Number (default = 0) — The AC distance of the triangle.
 
angle:Number (default = 360) — The value of the angle used to draw the shape.
 
rotation:Number (default = 0) — The rotation value of the shape.
 
x:Number (default = 0) — The x barycentre position of the triangle shape.
 
y:Number (default = 0) — The y barycentre position of the triangle shape.
Method Detail
draw()method
override public function draw(... arguments):void

Draws the shape.

Parameters

... arguments — (optional) The ab distance in pixels of the triangle pen.

drawShape()method 
override public 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 ab distance in pixels of the triangle pen.