| Package | graphics.drawing |
| Class | public class HexagonPen |
| Inheritance | HexagonPen Pen flash.utils.Proxy |
Example :
package examples
{
import graphics.Align;
import graphics.FillStyle;
import graphics.drawing.HexagonPen;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
public class HexagonPenExample extends Sprite
{
public function HexagonPenExample()
{
///////////
shape = new Shape() ;
shape.x = 740 / 2 ;
shape.y = 420 / 2 ;
pen = new HexagonPen( shape , 0, 0, 40, 45, Align.TOP_RIGHT ) ;
pen.fill = new FillStyle( 0xFF0000 , 0.6 ) ;
pen.draw() ;
addChild( shape ) ;
///////////
stage.scaleMode = StageScaleMode.NO_SCALE ;
stage.addEventListener( KeyboardEvent.KEY_DOWN , keyDown ) ;
stage.addEventListener( MouseEvent.MOUSE_DOWN , mouseDown ) ;
stage.addEventListener( MouseEvent.MOUSE_UP , mouseUp ) ;
}
public var pen:HexagonPen ;
public var shape:Shape ;
public function enterFrame( e:Event ):void
{
pen.angle += 15 ;
pen.draw() ;
}
public function keyDown( e:KeyboardEvent ):void
{
var code:uint = e.keyCode ;
switch( code )
{
case Keyboard.LEFT :
{
pen.draw( 0, 0, 40, 0, Align.LEFT ) ;
break ;
}
case Keyboard.RIGHT :
{
pen.draw( 0, 0, 40, 0, Align.RIGHT ) ;
break ;
}
case Keyboard.UP :
{
pen.draw( 0, 0, 40, 0, Align.TOP ) ;
break ;
}
case Keyboard.DOWN :
{
pen.useApothem = true ;
pen.draw( 0, 0, 40, 0, Align.BOTTOM ) ;
pen.useApothem = false ;
break ;
}
case Keyboard.SPACE :
{
pen.draw( 0, 0, 40, 0, Align.CENTER ) ;
break ;
}
}
}
public function mouseDown( e:MouseEvent ):void
{
stage.addEventListener( Event.ENTER_FRAME , enterFrame ) ;
}
public function mouseUp( e:MouseEvent ):void
{
stage.removeEventListener( Event.ENTER_FRAME , enterFrame ) ;
}
}
}
| Property | Defined By | ||
|---|---|---|---|
![]() | align : uint
Determinates the align value of the pen. | Pen | |
| angle : Number
Starting angle in degrees to draw the shape and defines the position of all the vertices (default to 0). | HexagonPen | ||
| apothem : Number
Determinates the size of the line segment from the center of a regular polygon to the midpoint of a side. | HexagonPen | ||
![]() | 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 | |
| height : Number
The height of the hexagon. | HexagonPen | ||
![]() | line : ILineStyle
Determinates the line style object of the pen. | Pen | |
| radius : Number
The radius size of the hexagon. | HexagonPen | ||
| useApothem : Boolean
Indicates if the pen use the apothem of the hexagon to draw the shape or the radius (to defines the y position). | HexagonPen | ||
![]() | 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 | |
| width : Number
The width of the hexagon. | HexagonPen | ||
| x : Number
The offset x value of the center of the circle. | HexagonPen | ||
| y : Number
The offset y value of the center of the circle. | HexagonPen | ||
| Method | Defined By | ||
|---|---|---|---|
HexagonPen(graphic:*, x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10)
The Pen class use composition to control a Graphics reference and draw custom vector graphic shapes. | HexagonPen | ||
![]() | 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. | HexagonPen | ||
drawShape():void [override]
This method contains the basic drawing shape algorithm. | HexagonPen | ||
![]() | 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(x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10):void
Sets the pen properties. | HexagonPen | ||
| angle | property |
angle:NumberStarting angle in degrees to draw the shape and defines the position of all the vertices (default to 0).
public function get angle():Number public function set angle(value:Number):void| apothem | property |
apothem:NumberDeterminates the size of the line segment from the center of a regular polygon to the midpoint of a side.
public function get apothem():Number public function set apothem(value:Number):void| height | property |
height:NumberThe height of the hexagon.
public function get height():Number public function set height(value:Number):void| radius | property |
radius:NumberThe radius size of the hexagon.
public function get radius():Number public function set radius(value:Number):void| useApothem | property |
public var useApothem:BooleanIndicates if the pen use the apothem of the hexagon to draw the shape or the radius (to defines the y position).
| width | property |
width:NumberThe width of the hexagon.
public function get width():Number public function set width(value:Number):void| x | property |
public var x:NumberThe offset x value of the center of the circle.
| y | property |
public var y:NumberThe offset y value of the center of the circle.
| HexagonPen | () | Constructor |
public function HexagonPen(graphic:*, x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10)The Pen class use composition to control a Graphics reference and draw custom vector graphic shapes.
Parametersgraphic:* — The Graphics reference to control with this helper. You can passed-in a Shape or Sprite/MovieClip reference in argument.
| |
x:Number (default = 0) — The x location of the center of the shape relative to the registration point of the parent display object (in pixels).
| |
y:Number (default = 0) — The y location of the center of the circle relative to the registration point of the parent display object (in pixels).
| |
radius:Number (default = 40) — The radius size of the hexagon (in pixels).
| |
angle:Number (default = 0) — (optional) The starting angle in degrees. (defaults to 0)
| |
align:uint (default = 10) — The alignement value to align the shape, by default use the Align.TOP_LEFT value (10).
|
| draw | () | method |
override public function draw(... arguments):voidDraws the shape.
Parameters
... arguments — The x location of the center of the shape relative to the registration point of the parent display object (in pixels).
|
| drawShape | () | method |
override public function drawShape():voidThis method contains the basic drawing shape algorithm.
| setPen | () | method |
public function setPen(x:Number = 0, y:Number = 0, radius:Number = 40, angle:Number = 0, align:uint = 10):voidSets the pen properties.
Parameters
x:Number (default = 0) — The x location of the center of the shape relative to the registration point of the parent display object (in pixels).
| |
y:Number (default = 0) — The y location of the center of the circle relative to the registration point of the parent display object (in pixels).
| |
radius:Number (default = 40) — The radius size of the hexagon (in pixels).
| |
angle:Number (default = 0) — (optional) The starting angle in degrees. (defaults to 0)
| |
align:uint (default = 10) — The alignement value to align the shape, by default use the Align.TOP_LEFT value (10).
|