| Package | graphics.drawing |
| Class | public class DistortPen |
| Inheritance | DistortPen Pen flash.utils.Proxy |
Example :
import graphics.drawing.DistortPen ;
stage.align = "tl" ;
stage.scaleMode = "noScale" ;
var shape:Shape = new Shape() ;
shape.x = 0 ;
shape.y = 0 ;
addChildAt( shape , 0 ) ;
var bmp:BitmapData = new Girl(0,0) ; // Girl a BitmapData linked in the library of the SWF.
var pen:DistortPen = new DistortPen( shape, bmp.width, bmp.height, 4, 4 ) ;
pen.bitmapData = bmp
pen.draw( p1 , p2 , p3 , p4 ) ;
var enterFrame:Function = function (e:Event ):void
{
pen.draw( p1, p2, p3, p4 ) ;
}
var onStartDrag:Function = function( e:Event ):void
{
if ( e.target is MovieClip )
{
(e.target as MovieClip).startDrag() ;
(e.target as MovieClip).addEventListener( Event.ENTER_FRAME , enterFrame ) ;
}
}
var onStopDrag:Function = function( e:Event ):void
{
if ( e.target is MovieClip )
{
(e.target as MovieClip).stopDrag() ;
(e.target as MovieClip).removeEventListener( Event.ENTER_FRAME , enterFrame ) ;
}
}
// p1, p2, p3 and p4 are 4 little anchor MovieClip in the stage of the application.
p1.buttonMode = true ;
p1.useHandCursor = true ;
p1.addEventListener( MouseEvent.MOUSE_DOWN , onStartDrag ) ;
p1.addEventListener( MouseEvent.MOUSE_UP , onStopDrag ) ;
p2.buttonMode = true ;
p2.useHandCursor = true ;
p2.addEventListener( MouseEvent.MOUSE_DOWN , onStartDrag ) ;
p2.addEventListener( MouseEvent.MOUSE_UP , onStopDrag ) ;
p3.buttonMode = true ;
p3.useHandCursor = true ;
p3.addEventListener( MouseEvent.MOUSE_DOWN , onStartDrag ) ;
p3.addEventListener( MouseEvent.MOUSE_UP , onStopDrag ) ;
p4.buttonMode = true ;
p4.useHandCursor = true ;
p4.addEventListener( MouseEvent.MOUSE_DOWN , onStartDrag ) ;
p4.addEventListener( MouseEvent.MOUSE_UP , onStopDrag ) ;
| Property | Defined By | ||
|---|---|---|---|
![]() | align : uint
Determinates the align value of the pen. | Pen | |
| bitmapData : BitmapData
Determinates the BitmapData reference of the distort pen. | DistortPen | ||
| bl : *
The bottom left point of the distortion. | DistortPen | ||
| br : *
The bottom right point of the distortion. | DistortPen | ||
![]() | 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
Indicates the height value of the pen. | DistortPen | ||
| hPrecision : uint
Indicates the horizontal precision of the pen. | DistortPen | ||
![]() | line : ILineStyle
Determinates the line style object of the pen. | Pen | |
| smoothing : Boolean = true
Indicates whether or not use pixel smoothing render. | DistortPen | ||
| tl : *
The top left point of the distortion. | DistortPen | ||
| tr : *
The top right point of the distortion. | DistortPen | ||
![]() | 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 | |
| vPrecision : uint
Indicates the vertical precision precision of the pen. | DistortPen | ||
| width : Number
Determinates the width of this distort pen. | DistortPen | ||
| Method | Defined By | ||
|---|---|---|---|
DistortPen(graphic:*, width:Number = 0, height:Number = 0, hPrecision:uint = 2, vPrecision:uint = 2, bitmapData:BitmapData = null)
Creates a new DistorPen instance. | DistortPen | ||
![]() | 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(... args):void [override]
Draws the shape and distorts the BitmapData according to the provided Point instances and draws it into the provided Graphics. | DistortPen | ||
drawShape():void [override]
This method contains the basic drawing shape algorithm. | DistortPen | ||
![]() | 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(... args):void
Sets the shape options to defined all values to draw the shape. | DistortPen | ||
setPrecision(hPrecision:Number, vPrecision:Number):void
Sets the precision of this distort pen instance and re-initializes the triangular grid. | DistortPen | ||
setSize(width:Number, height:Number):void
Sets the size of this pen and re-initializes the triangular grid. | DistortPen | ||
| Method | Defined By | ||
|---|---|---|---|
init():void
Tesselates the area into triangles. | DistortPen | ||
| bitmapData | property |
bitmapData:BitmapDataDeterminates the BitmapData reference of the distort pen.
public function get bitmapData():BitmapData public function set bitmapData(value:BitmapData):void| bl | property |
public var bl:*The bottom left point of the distortion.
Note : This point must be an object with the x and y attributes (Point, Vector2, generic object, DisplayObject, etc.
| br | property |
public var br:*The bottom right point of the distortion.
Note : This point must be an object with the x and y attributes (Point, Vector2, generic object, DisplayObject, etc.
| height | property |
height:NumberIndicates the height value of the pen.
public function get height():Number public function set height(value:Number):void| hPrecision | property |
hPrecision:uintIndicates the horizontal precision of the pen.
public function get hPrecision():uint public function set hPrecision(value:uint):void| smoothing | property |
public var smoothing:Boolean = trueIndicates whether or not use pixel smoothing render.
| tl | property |
public var tl:*The top left point of the distortion.
Note : This point must be an object with the x and y attributes (Point, Vector2, generic object, DisplayObject, etc.
| tr | property |
public var tr:*The top right point of the distortion.
Note : This point must be an object with the x and y attributes (Point, Vector2, generic object, DisplayObject, etc.
| vPrecision | property |
vPrecision:uintIndicates the vertical precision precision of the pen.
public function get vPrecision():uint public function set vPrecision(value:uint):void| width | property |
width:NumberDeterminates the width of this distort pen.
public function get width():Number public function set width(value:Number):void| DistortPen | () | Constructor |
public function DistortPen(graphic:*, width:Number = 0, height:Number = 0, hPrecision:uint = 2, vPrecision:uint = 2, bitmapData:BitmapData = null)Creates a new DistorPen instance.
Parametersgraphic:* — The Graphics reference to control with this helper. You can passed-in a Shape or Sprite/MovieClip reference in argument.
| |
width:Number (default = 0) — The width of the picture to be processed (default 0).
| |
height:Number (default = 0) — The height of the picture to be processed (default 0).
| |
hPrecision:uint (default = 2) — The horizontal precision value (default 2).
| |
vPrecision:uint (default = 2) — The vertical precision value (default 2).
| |
bitmapData:BitmapData (default = null) |
| draw | () | method |
override public function draw(... args):voidDraws the shape and distorts the BitmapData according to the provided Point instances and draws it into the provided Graphics.
Parameters
... args — The position object specifying the coordinates of the top-left corner of the distortion.
|
| drawShape | () | method |
override public function drawShape():voidThis method contains the basic drawing shape algorithm.
| init | () | method |
protected function init():voidTesselates the area into triangles.
| setPen | () | method |
public function setPen(... args):voidSets the shape options to defined all values to draw the shape.
Parameters
... args — Point specifying the coordinates of the top-left corner of the distortion.
|
| setPrecision | () | method |
public function setPrecision(hPrecision:Number, vPrecision:Number):voidSets the precision of this distort pen instance and re-initializes the triangular grid.
Parameters
hPrecision:Number — The horizontal precision.
| |
vPrecision:Number — The vertical precision.
|
| setSize | () | method |
public function setSize(width:Number, height:Number):voidSets the size of this pen and re-initializes the triangular grid.
Parameters
width:Number — New width value.
| |
height:Number — New height value.
|