Fork me on GitHub
View source

package com.haxepunk.graphics

class Canvas


extends Graphic
extended by Backdrop, Tilemap

A multi-purpose drawing canvas, can be sized beyond the normal Flash BitmapData limits. Works only on flash and html5 targets.

Constructor

View source

new (width : Int, height : Int) : Void

Constructor.


Parameters:
width   

Width of the canvas.

height   

Height of the canvas.

Variables

alpha : Float

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

angle : Float

Rotation of the canvas, in degrees.

blend : BlendMode

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

color : Int

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

read only height : Int

Height of the canvas.

scale : Float

Scale of the canvas, effects both x and y scale.

scaleX : Float

X scale of the canvas.

scaleY : Float

Y scale of the canvas.

read only width : Int

Width of the canvas.

Functions

View source

draw (x : Float, y : Float, source : BitmapData, ?rect : Rectangle) : Void

Draws to the canvas.


Parameters:
x   

X position to draw.

y   

Y position to draw.

source   

Source BitmapData.

rect   

Optional area of the source image to draw from. If null, the entire BitmapData will be drawn.

View source

drawGraphic (x : Int, y : Int, source : Graphic) : Void

Draws the Graphic object to the canvas.


Parameters:
x   

X position to draw.

y   

Y position to draw.

source   

Graphic to draw.

View source

drawRect (rect : Rectangle, color : Int = 0, alpha : Float = 1) : Void

Draws over a rectangular area of the canvas.


Parameters:
rect   

Drawing rectangle.

color   

Draw color.

alpha   

Draw alpha. If < 1, this rectangle will blend with existing contents of the canvas.

View source

fill (rect : Rectangle, color : Int = 0, alpha : Float = 1) : Void

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


Parameters:
rect   

Fill rectangle.

color   

Fill color.

alpha   

Fill alpha.

View source

fillTexture (rect : Rectangle, texture : BitmapData) : Void

Fills the rectangle area of the canvas with the texture.


Parameters:
rect   

Fill rectangle.

texture   

Fill texture.

View source

shift (x : Int = 0, y : Int = 0) : Void

Shifts the canvas' pixels by the offset.


Parameters:
x   

Horizontal shift.

y   

Vertical shift.