API Docs for: 1.4.0
Show:

Kiwi.Utils.Canvas Class

Defined in: src\utils\Canvas.ts:8
Module: Utils
Parent Module: Kiwi

Creates and the manages a Canvas DOMElement.

Constructor

Kiwi.Utils.Canvas

(
  • width
  • height
  • [visible=true]
  • [offScreen=false]
)
Kiwi.Utils.Canvas

Parameters:

  • width Number

    The width of the canvas.

  • height Number

    The height of the canvas.

  • [visible=true] Boolean optional

    If the canvas is visible or not.

  • [offScreen=false] Boolean optional

    If the canvas is designed to be offscreen or not.

Returns:

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:

String:

"Canvas"

saveAsPNG

() public

Returns the canvas current image data as PNG.

Returns:

String

toString

() String public

Returns a string representation of this object.

Returns:

String:

a string representation of the instance.

Properties

_bgColor

Kiwi.Utils.Color private

Defined in src\utils\Canvas.ts:204

Available since 1.2.0

Background color object.

_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.