CanvasLayer
Source: canvas-layers.
Class representing the layers drawn on the canvas.
Methods
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 |
|
height |
|
Yes |
The height of the layer on the canvas. Defaults to |
|
rotation |
|
Yes |
The rotation of the layer on the canvas. Defaults to |
|
draggable |
|
Yes |
Is the layer draggable? Defaults to |
|
rotateable |
|
Yes |
Is the layer rotateable? Defaults to |
|
resizable |
|
Yes |
Is the layer resizable? Defaults to |
|
selectable |
|
Yes |
Is the layer selectable? Defaults to |
|
forceBoundary |
|
Yes |
Force the layer to stay in bounds? Defaults to |
- Returns
Methods
deobjectify(str) → CanvasLayer
un Serialize a layer
Parameter
| Name | Type | Optional | Description |
|---|---|---|---|
|
str |
type |
|
- Returns
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