new CanvasLayer(url, name, x, y[, width][, height][, rotation][, draggable][, rotateable][, resizable][, selectable][, forceBoundary])

Create a new Layer.

Parameters

Name Type Optional Description

url

 

 

The URL or URI of an image to draw on the canvas.

name

 

 

The name of the layer.

x

 

 

The x position of the layer on the canvas.

y

 

 

The y position of the layer on the canvas.

width

 

Yes

The width of the layer on the canvas.

Defaults to null.

height

 

Yes

The height of the layer on the canvas.

Defaults to null.

rotation

 

Yes

The rotation of the layer on the canvas.

Defaults to 0.

draggable

 

Yes

Is the layer draggable?

Defaults to true.

rotateable

 

Yes

Is the layer rotateable?

Defaults to true.

resizable

 

Yes

Is the layer resizable?

Defaults to true.

selectable

 

Yes

Is the layer selectable?

Defaults to true.

forceBoundary

 

Yes

Force the layer to stay in bounds?

Defaults to false.

Returns

Methods

static

deobjectify(str) → CanvasLayer

un Serialize a layer

Parameter

Name Type Optional Description

str

type

 

Returns

CanvasLayer 

load() → Promise

Load the layer so it is ready to use.

Returns

Promise - A promise that resolves when the layer is ready

objectify() → String

jsonify the current layer

Returns

String - Serialized layer

onload(fn) → undefined

Register a function to be called when the layer is fully loaded.

Parameter

Name Type Optional Description

fn

function()

 

The callback function.

Returns

undefined