Packagenet.flashpunk.utils
Classpublic class Draw
InheritanceDraw Inheritance Object

Static class with access to miscellaneous drawing functions. These functions are not meant to replace Graphic components for Entities, but rather to help with testing and debugging.



Public Properties
 PropertyDefined By
  blend : String
[static] The blending mode used by Draw functions.
Draw
Public Methods
 MethodDefined By
  
circle(x:int, y:int, radius:int, color:uint = 0xFFFFFF):void
[static] Draws a non-filled, pixelated circle.
Draw
  
circlePlus(x:Number, y:Number, radius:Number, color:uint = 0xFFFFFF, alpha:Number = 1, fill:Boolean = true, thick:Number = 1):void
[static] Draws a circle to the screen.
Draw
  
curve(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, color:uint = 0, alpha:Number = 1, thick:Number = 1):void
[static] Draws a quadratic curve.
Draw
  
ellipse(x:Number, y:Number, width:Number, height:Number, color:uint = 0xFFFFFF, alpha:Number = 1, fill:Boolean = true, thick:Number = 1, angle:Number = 0):void
[static] Draws an ellipse to the screen.
Draw
  
entity(e:Entity, x:int = 0, y:int = 0, addEntityPosition:Boolean = false):void
[static] Draws an Entity object.
Draw
  
graphic(g:Graphic, x:int = 0, y:int = 0):void
[static] Draws a graphic object.
Draw
  
hitbox(e:Entity, outline:Boolean = true, color:uint = 0xFFFFFF, alpha:Number = 1):void
[static] Draws the Entity's hitbox.
Draw
  
line(x1:int, y1:int, x2:int, y2:int, color:uint = 0xFFFFFF, overwriteAlpha:Number = 1.0):void
[static] Draws a pixelated, non-antialiased line.
Draw
  
linePlus(x1:Number, y1:Number, x2:Number, y2:Number, color:uint = 0xFF000000, alpha:Number = 1, thick:Number = 1):void
[static] Draws a smooth, antialiased line with optional alpha and thickness.
Draw
  
rect(x:Number, y:Number, width:Number, height:Number, color:uint = 0xFFFFFF, alpha:Number = 1, overwrite:Boolean = false):void
[static] Draws a filled rectangle.
Draw
  
rectPlus(x:Number, y:Number, width:Number, height:Number, color:uint = 0xFFFFFF, alpha:Number = 1, fill:Boolean = true, thick:Number = 1, radius:Number = 0):void
[static] Draws a rectangle.
Draw
  
[static] Resets the drawing target to the default.
Draw
  
setTarget(target:BitmapData, camera:Point = null, blend:String = null):void
[static] Sets the drawing target for Draw functions.
Draw
  
text(text:String, x:Number = 0, y:Number = 0, options:Object = null):void
[static] Draws text.
Draw
Property Detail
blendproperty
public static var blend:String

The blending mode used by Draw functions. This will not apply to Draw.line() or Draw.circle(), but will apply to Draw.linePlus() and Draw.circlePlus().

Method Detail
circle()method
public static function circle(x:int, y:int, radius:int, color:uint = 0xFFFFFF):void

Draws a non-filled, pixelated circle.

Parameters

x:int — Center x position.
 
y:int — Center y position.
 
radius:int — Radius of the circle.
 
color:uint (default = 0xFFFFFF) — Color of the circle.

circlePlus()method 
public static function circlePlus(x:Number, y:Number, radius:Number, color:uint = 0xFFFFFF, alpha:Number = 1, fill:Boolean = true, thick:Number = 1):void

Draws a circle to the screen.

Parameters

x:Number — X position of the circle's center.
 
y:Number — Y position of the circle's center.
 
radius:Number — Radius of the circle.
 
color:uint (default = 0xFFFFFF) — Color of the circle.
 
alpha:Number (default = 1) — Alpha of the circle.
 
fill:Boolean (default = true) — If the circle should be filled with the color (true) or just an outline (false).
 
thick:Number (default = 1) — How thick the outline should be (only applicable when fill = false).

curve()method 
public static function curve(x1:Number, y1:Number, x2:Number, y2:Number, x3:Number, y3:Number, color:uint = 0, alpha:Number = 1, thick:Number = 1):void

Draws a quadratic curve.

Parameters

x1:Number — X start.
 
y1:Number — Y start.
 
x2:Number — X control point, used to determine the curve.
 
y2:Number — Y control point, used to determine the curve.
 
x3:Number — X finish.
 
y3:Number — Y finish.
 
color:uint (default = 0) — Color of the curve
 
alpha:Number (default = 1) — Alpha transparency.
 
thick:Number (default = 1)

ellipse()method 
public static function ellipse(x:Number, y:Number, width:Number, height:Number, color:uint = 0xFFFFFF, alpha:Number = 1, fill:Boolean = true, thick:Number = 1, angle:Number = 0):void

Draws an ellipse to the screen.

Parameters

x:Number — X position of the ellipse's center.
 
y:Number — Y position of the ellipse's center.
 
width:Number — Width of the ellipse.
 
height:Number — Height of the ellipse.
 
color:uint (default = 0xFFFFFF) — Color of the ellipse.
 
alpha:Number (default = 1) — Alpha of the ellipse.
 
fill:Boolean (default = true) — If the ellipse should be filled with the color (true) or just an outline (false).
 
thick:Number (default = 1) — How thick the outline should be (only applicable when fill = false).
 
angle:Number (default = 0) — What angle (in degrees) the ellipse should be rotated.

entity()method 
public static function entity(e:Entity, x:int = 0, y:int = 0, addEntityPosition:Boolean = false):void

Draws an Entity object.

Parameters

e:Entity — The Entity to draw.
 
x:int (default = 0) — X position.
 
y:int (default = 0) — Y position.
 
addEntityPosition:Boolean (default = false) — Adds the Entity's x and y position to the target position.

graphic()method 
public static function graphic(g:Graphic, x:int = 0, y:int = 0):void

Draws a graphic object.

Parameters

g:Graphic — The Graphic to draw.
 
x:int (default = 0) — X position.
 
y:int (default = 0) — Y position.

hitbox()method 
public static function hitbox(e:Entity, outline:Boolean = true, color:uint = 0xFFFFFF, alpha:Number = 1):void

Draws the Entity's hitbox.

Parameters

e:Entity — The Entity whose hitbox is to be drawn.
 
outline:Boolean (default = true) — If just the hitbox's outline should be drawn.
 
color:uint (default = 0xFFFFFF) — Color of the hitbox.
 
alpha:Number (default = 1) — Alpha of the hitbox.

line()method 
public static function line(x1:int, y1:int, x2:int, y2:int, color:uint = 0xFFFFFF, overwriteAlpha:Number = 1.0):void

Draws a pixelated, non-antialiased line.

Parameters

x1:int — Starting x position.
 
y1:int — Starting y position.
 
x2:int — Ending x position.
 
y2:int — Ending y position.
 
color:uint (default = 0xFFFFFF) — Color of the line.
 
overwriteAlpha:Number (default = 1.0) — Alpha value written to these pixels: does NOT do blending. If you want to draw a semi-transparent line over some other content, you will have to either: A) use Draw.linePlus() or B) if non-antialiasing is important, render with Draw.line() to an intermediate buffer with transparency and then render that intermediate buffer.

linePlus()method 
public static function linePlus(x1:Number, y1:Number, x2:Number, y2:Number, color:uint = 0xFF000000, alpha:Number = 1, thick:Number = 1):void

Draws a smooth, antialiased line with optional alpha and thickness.

Parameters

x1:Number — Starting x position.
 
y1:Number — Starting y position.
 
x2:Number — Ending x position.
 
y2:Number — Ending y position.
 
color:uint (default = 0xFF000000) — Color of the line.
 
alpha:Number (default = 1) — Alpha of the line.
 
thick:Number (default = 1) — The thickness of the line.

rect()method 
public static function rect(x:Number, y:Number, width:Number, height:Number, color:uint = 0xFFFFFF, alpha:Number = 1, overwrite:Boolean = false):void

Draws a filled rectangle.

Parameters

x:Number — X position of the rectangle.
 
y:Number — Y position of the rectangle.
 
width:Number — Width of the rectangle.
 
height:Number — Height of the rectangle.
 
color:uint (default = 0xFFFFFF) — Color of the rectangle.
 
alpha:Number (default = 1) — Alpha of the rectangle.
 
overwrite:Boolean (default = false) — If the color/alpha provided should replace the existing data rather than blend.

rectPlus()method 
public static function rectPlus(x:Number, y:Number, width:Number, height:Number, color:uint = 0xFFFFFF, alpha:Number = 1, fill:Boolean = true, thick:Number = 1, radius:Number = 0):void

Draws a rectangle.

Parameters

x:Number — X position of the rectangle.
 
y:Number — Y position of the rectangle.
 
width:Number — Width of the rectangle.
 
height:Number — Height of the rectangle.
 
color:uint (default = 0xFFFFFF) — Color of the rectangle.
 
alpha:Number (default = 1) — Alpha of the rectangle.
 
fill:Boolean (default = true) — If the rectangle should be filled with the color (true) or just an outline (false).
 
thick:Number (default = 1) — How thick the outline should be (only applicable when fill = false).
 
radius:Number (default = 0) — Round rectangle corners by this amount.

resetTarget()method 
public static function resetTarget():void

Resets the drawing target to the default. The same as calling Draw.setTarget(FP.buffer, FP.camera).

setTarget()method 
public static function setTarget(target:BitmapData, camera:Point = null, blend:String = null):void

Sets the drawing target for Draw functions.

Parameters

target:BitmapData — The buffer to draw to.
 
camera:Point (default = null) — The camera offset (use null for none).
 
blend:String (default = null) — The blend mode to use.

text()method 
public static function text(text:String, x:Number = 0, y:Number = 0, options:Object = null):void

Draws text.

Parameters

text:String — The text to render.
 
x:Number (default = 0) — X position.
 
y:Number (default = 0) — Y position.
 
options:Object (default = null) — Options (see Text constructor).