| Package | net.flashpunk.graphics |
| Class | public class Canvas |
| Inheritance | Canvas Graphic Object |
| Subclasses | Backdrop, Tilemap |
| Property | Defined By | ||
|---|---|---|---|
![]() | active : 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 | ||
![]() | relative : Boolean = true
If the graphic should render at its position relative to its parent Entity's position. | Graphic | |
![]() | scrollX : Number = 1
X scrollfactor, effects how much the camera offsets the drawn graphic. | Graphic | |
![]() | scrollY : Number = 1
Y scrollfactor, effects how much the camera offsets the drawn graphic. | Graphic | |
![]() | visible : Boolean = true
If the graphic should render. | Graphic | |
| width : uint [read-only]
Width of the canvas. | Canvas | ||
![]() | x : Number = 0
X offset. | Graphic | |
![]() | y : Number = 0
Y offset. | Graphic | |
| Method | Defined 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 | ||
![]() | 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 | ||
![]() | update():void
Updates the graphic. | Graphic | |
| _rect | property |
protected var _rect:Rectangle
| alpha | property |
alpha:NumberChange the opacity of the Canvas, a value from 0 to 1.
public function get alpha():Number public function set alpha(value:Number):void| blend | property |
public var blend:StringOptional blend mode to use (see flash.display.BlendMode for blending modes).
| color | property |
color:uintThe tinted color of the Canvas. Use 0xFFFFFF to draw the it normally.
public function get color():uint public function set color(value:uint):void| height | property |
height:uint [read-only] Height of the canvas.
public function get height():uint| width | property |
width:uint [read-only] Width of the canvas.
public function get width():uint| Canvas | () | Constructor |
public function Canvas(width:uint, height:uint)Constructor.
Parameterswidth:uint — Width of the canvas.
| |
height:uint — Height of the canvas.
|
| applyFilter | () | method |
public function applyFilter(filter:BitmapFilter):voidParameters
filter:BitmapFilter |
| copyPixels | () | method |
public function copyPixels(source:BitmapData, rect:Rectangle, destPoint:Point, alphaBitmapData:BitmapData = null, alphaPoint:Point = null, mergeAlpha:Boolean = false):voidMimics 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):voidDraws 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):voidDraws 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):voidDraws 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):voidFills 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):voidFills 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):uintParameters
x:int | |
y:int |
uint |
| setPixel | () | method |
public function setPixel(x:int, y:int, color:uint):voidParameters
x:int | |
y:int | |
color:uint |
| shift | () | method |
public function shift(x:int = 0, y:int = 0):voidShifts the canvas' pixels by the offset.
Parameters
x:int (default = 0) — Horizontal shift.
| |
y:int (default = 0) — Vertical shift.
|