| Package | graphics.drawing |
| Class | public dynamic class TrianglePen |
| Inheritance | TrianglePen Pen flash.utils.Proxy |
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 ;
}
}
}
| Property | Defined 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 | ||
![]() | align : 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 | ||
![]() | fill : IFillStyle
Determinates the fill style object of the pen. | Pen | |
![]() | graphics : *
Specifies the Graphics object belonging to this Shape object, where vector drawing commands can occur. | Pen | |
![]() | line : ILineStyle
Determinates the line style object of the pen. | Pen | |
| rotation : Number
Indicates the rotation value of the shape. | TrianglePen | ||
![]() | useClear : Boolean = true
Indicates if the clear() method is invoked at the end of the draw method. | Pen | |
![]() | useEndFill : 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 | ||
| Method | Defined 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 | ||
![]() | BF(... arguments):void
Defines a shortcut reference to used the beginBitmapFill method. | Pen | |
![]() | C(... arguments):void
Defines a shortcut reference to used the curveTo method. | Pen | |
![]() | 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 | ||
![]() | EF():void
Defines a shortcut reference to used the endFill method. | Pen | |
![]() | F(... arguments):void
Defines a shortcut reference to used the beginFill method. | Pen | |
![]() | GF(... arguments):void
Defines a shortcut reference to used the beginGradientFill method. | Pen | |
![]() | GS(... arguments):void
Defines a shortcut reference to used the lineGradientStyle method. | Pen | |
![]() | L(... arguments):void
Defines a shortcut reference to used the lineTo method. | Pen | |
![]() | M(... arguments):void
Defines a shortcut reference to used the moveTo method. | Pen | |
![]() | 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 | ||
| a | property |
a:Point [read-only] Indicates the A corner position of the triangle.
public function get a():Point| ab | property |
ab:NumberIndicates the AB distance of the triangle.
public function get ab():Number public function set ab(value:Number):void| ac | property |
ac:NumberIndicates the AC distance of the triangle.
public function get ac():Number public function set ac(value:Number):void| angle | property |
angle:NumberIndicates the value of the angle used to draw the shape.
public function get angle():Number public function set angle(value:Number):void| b | property |
b:Point [read-only] Indicates the B corner position of the triangle.
public function get b():Point| barycenter | property |
barycenter:Point [read-only] Indicates a new barycenter Point object of the triangle.
public function get barycenter():Point| c | property |
c:Point [read-only] Indicates the C corner position of the triangle.
public function get c():Point| rotation | property |
rotation:NumberIndicates the rotation value of the shape.
public function get rotation():Number public function set rotation(value:Number):void| x | property |
x:NumberDefines the x barycentre position of the triangle shape.
public function get x():Number public function set x(value:Number):void| y | property |
y:NumberDefines the y barycentre position of the triangle shape.
public function get y():Number public function set y(value:Number):void| 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.
Parametersgraphic:* — 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.
|
| draw | () | method |
override public function draw(... arguments):voidDraws the shape.
Parameters
... arguments — (optional) The ab distance in pixels of the triangle pen.
|
| drawShape | () | method |
override public function drawShape():voidThis method contains the basic drawing shape algorithm.
| setPen | () | method |
public function setPen(... arguments):voidSets the shape options to defined all values to draw the shape.
Parameters
... arguments — (optional) The ab distance in pixels of the triangle pen.
|