Kiwi.Utils.Canvas Class
Creates and the manages a Canvas DOMElement.
Constructor
Kiwi.Utils.Canvas
-
width
-
height
-
[visible=true]
-
[offScreen=false]
Parameters:
-
width
NumberThe width of the canvas.
-
height
NumberThe height of the canvas.
-
[visible=true]
Boolean optionalIf the canvas is visible or not.
-
[offScreen=false]
Boolean optionalIf the canvas is designed to be offscreen or not.
Returns:
Item Index
Properties
- _bgColor
- _clearMode
- _context
- _height
- _offScreen
- _visible
- _width
- bgColor
- clearMode
- CLEARMODE_CLEARRECT static
- CLEARMODE_FILLRECT static
- CLEARMODE_FILLRECT_ALPHA static
- CLEARMODE_NONE static
- domElement
- height
- visible
- width
Methods
_updatedSize
()
private
Updates the width/height on the canvas DOM element when either one of its sizes are updated.
clear
()
public
Clears the canvas using the method specified by the clearMode property.
destroy
()
public
Used to remove the canvas element completely along with this class. [NEEDS IMPLEMENTATION]
objType
()
String
public
The type of object that this is.
Returns:
"Canvas"
saveAsPNG
()
public
Returns the canvas current image data as PNG.
Returns:
String
toString
()
String
public
Returns a string representation of this object.
Returns:
a string representation of the instance.
Properties
_clearMode
Number
private
The method to use when clearing the canvas.
_context
CanvasRenderingContext2D
public
The 2D rendering context that is used to render anything to this canvas.
_height
Number
private
The height of this canvas.
_offScreen
Boolean
private
If the canvas is offscreen or not.
_visible
Boolean
private
If the canvas element is visible or not.
_width
Number
private
The width of this canvas.
bgColor
String
public
The background color to use clearing the canvas using a filled rectangle approach. You may set this with any valid Kiwi.Utils.Color parameter. If you set with multiple parameters, place them inside an array.
Default: "#000000"
clearMode
Number
public
The clearmode the is to be used when clearing the canvas.
Default: 1
CLEARMODE_CLEARRECT
Number
public
final
static
A STATIC property that holds the number associated with the clear mode that uses the clearRect method to clear the canvas.
Default: 1
CLEARMODE_FILLRECT
Number
public
final
static
A STATIC property that holds the number associated with the clear mode that uses a filled rectangle to clear the canvas.
Default: 2
CLEARMODE_FILLRECT_ALPHA
Number
public
final
static
A STATIC property that holds the number associated with the clear mode that uses the filled alpha rectangle method.
Default: 3
CLEARMODE_NONE
Number
public
final
static
A STATIC property that holds the number associated with no clear mode.
Default: 0
domElement
HTMLCanvasElement
public
The canvas DOM element.
height
Number
private
The height of this canvas.
visible
Boolean
public
If the canvas element is visible or not.
Default: true
width
Number
public
The width of this canvas.