Packagenet.flashpunk.graphics
Classpublic class Canvas
InheritanceCanvas Inheritance Graphic Inheritance Object
Subclasses Backdrop, Tilemap

A multi-purpose drawing canvas, can be sized beyond the normal Flash BitmapData limits.



Public Properties
 PropertyDefined By
 Inheritedactive : Boolean = false
If the graphic should update.
Graphic
  alpha : Number
Change the opacity of the Canvas, a value from 0 to 1.
Canvas
  blend : String
Optional blend mode to use (see flash.display.BlendMode for blending modes).
Canvas
  color : uint
The tinted color of the Canvas.
Canvas
  height : uint
[read-only] Height of the canvas.
Canvas
 Inheritedrelative : Boolean = true
If the graphic should render at its position relative to its parent Entity's position.
Graphic
 InheritedscrollX : Number = 1
X scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
 InheritedscrollY : Number = 1
Y scrollfactor, effects how much the camera offsets the drawn graphic.
Graphic
 Inheritedvisible : Boolean = true
If the graphic should render.
Graphic
  width : uint
[read-only] Width of the canvas.
Canvas
 Inheritedx : Number = 0
X offset.
Graphic
 Inheritedy : Number = 0
Y offset.
Graphic
Protected Properties
 PropertyDefined By
 Inheritedassign : Function
Graphic
  _rect : Rectangle
Canvas
Public Methods
 MethodDefined By
  
Canvas(width:uint, height:uint)
Constructor.
Canvas
  
applyFilter(filter:BitmapFilter):void
Canvas
  
copyPixels(source:BitmapData, rect:Rectangle, destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null, mergeAlpha:Boolean = false):void
Mimics BitmapData's copyPixels method.
Canvas
  
draw(x:int, y:int, source:BitmapData, rect:Rectangle = null):void
Draws to the canvas.
Canvas
  
drawGraphic(x:int, y:int, source:Graphic):void
Draws the Graphic object to the canvas.
Canvas
  
drawRect(rect:Rectangle, color:uint = 0, alpha:Number = 1):void
Draws over a rectangular area of the canvas.
Canvas
  
fill(rect:Rectangle, color:uint = 0, alpha:Number = 1):void
Fills the rectangular area of the canvas.
Canvas
  
fillTexture(rect:Rectangle, texture:BitmapData):void
Fills the rectangle area of the canvas with the texture.
Canvas
  
getPixel(x:int, y:int):uint
Canvas
 Inherited
render(target:BitmapData, point:Point, camera:Point):void
Renders the graphic to the screen buffer.
Graphic
  
setPixel(x:int, y:int, color:uint):void
Canvas
  
shift(x:int = 0, y:int = 0):void
Shifts the canvas' pixels by the offset.
Canvas
 Inherited
update():void
Updates the graphic.
Graphic
Property Detail
_rectproperty
protected var _rect:Rectangle

alphaproperty 
alpha:Number

Change the opacity of the Canvas, a value from 0 to 1.


Implementation
    public function get alpha():Number
    public function set alpha(value:Number):void
blendproperty 
public var blend:String

Optional blend mode to use (see flash.display.BlendMode for blending modes).

colorproperty 
color:uint

The tinted color of the Canvas. Use 0xFFFFFF to draw the it normally.


Implementation
    public function get color():uint
    public function set color(value:uint):void
heightproperty 
height:uint  [read-only]

Height of the canvas.


Implementation
    public function get height():uint
widthproperty 
width:uint  [read-only]

Width of the canvas.


Implementation
    public function get width():uint
Constructor Detail
Canvas()Constructor
public function Canvas(width:uint, height:uint)

Constructor.

Parameters
width:uint — Width of the canvas.
 
height:uint — Height of the canvas.
Method Detail
applyFilter()method
public function applyFilter(filter:BitmapFilter):void

Parameters

filter:BitmapFilter

copyPixels()method 
public function copyPixels(source:BitmapData, rect:Rectangle, destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null, mergeAlpha:Boolean = false):void

Mimics BitmapData's copyPixels method.

Parameters

source:BitmapData — Source BitmapData.
 
rect:Rectangle — Area of the source image to draw from.
 
destPoint:Point — Position to draw at.
 
alphaBitmapData:BitmapData (default = null) — See BitmapData documentation for details.
 
alphaPoint:Point (default = null) — See BitmapData documentation for details.
 
mergeAlpha:Boolean (default = false) — See BitmapData documentation for details.

draw()method 
public function draw(x:int, y:int, source:BitmapData, rect:Rectangle = null):void

Draws to the canvas.

Parameters

x:int — X position to draw.
 
y:int — Y position to draw.
 
source:BitmapData — Source BitmapData.
 
rect:Rectangle (default = null) — Optional area of the source image to draw from. If null, the entire BitmapData will be drawn.

drawGraphic()method 
public function drawGraphic(x:int, y:int, source:Graphic):void

Draws the Graphic object to the canvas.

Parameters

x:int — X position to draw.
 
y:int — Y position to draw.
 
source:Graphic — Graphic to draw.

drawRect()method 
public function drawRect(rect:Rectangle, color:uint = 0, alpha:Number = 1):void

Draws over a rectangular area of the canvas.

Parameters

rect:Rectangle — Drawing rectangle.
 
color:uint (default = 0) — Draw color.
 
alpha:Number (default = 1) — Draw alpha. If < 1, this rectangle will blend with existing contents of the canvas.

fill()method 
public function fill(rect:Rectangle, color:uint = 0, alpha:Number = 1):void

Fills the rectangular area of the canvas. The previous contents of that area are completely removed.

Parameters

rect:Rectangle — Fill rectangle.
 
color:uint (default = 0) — Fill color.
 
alpha:Number (default = 1) — Fill alpha.

fillTexture()method 
public function fillTexture(rect:Rectangle, texture:BitmapData):void

Fills the rectangle area of the canvas with the texture.

Parameters

rect:Rectangle — Fill rectangle.
 
texture:BitmapData — Fill texture.

getPixel()method 
public function getPixel(x:int, y:int):uint

Parameters

x:int
 
y:int

Returns
uint
setPixel()method 
public function setPixel(x:int, y:int, color:uint):void

Parameters

x:int
 
y:int
 
color:uint

shift()method 
public function shift(x:int = 0, y:int = 0):void

Shifts the canvas' pixels by the offset.

Parameters

x:int (default = 0) — Horizontal shift.
 
y:int (default = 0) — Vertical shift.