Class: Layer
Simple layer objects that are managed within the LayerHash.
Implements
Layer Method: constructor
Syntax
var layer = new Layer( options );
Arguments
- options - (object) The options for the layer.
Options
- id - (string, required) The id for the layer.
- visible (bool, defaults to true) Determines whether the layer is rendered.
Returns
- (object) Layer instance
Layer Method: add
Adds an item to the layer.
Syntax
layer.add( item );
Arguments
- item - (object) Item to add.
Returns
- (object) CanvasItem instance
Layer Method: get
Returns an item.
Syntax
layer.get( itemId );
Arguments
- itemId - (string) Id of the Item to return.
Returns
- (object) CanvasItem instance
Layer Method: remove
Removes an item from the layer and fires the item's destroy event.
Syntax
layer.remove( itemId );
Arguments
- itemId - (string) Id of the Item to return.
Returns
- (null)
Layer Method: toggle
Toggles the visibility of the layer. Visibility may also be set directly through layer.options.visible
Syntax
layer.toggle( );
Returns
- (object) Layer instance
Layer Method: draw
Draws all items on the layer. Usually called by the LayerHash's draw method(which in turn is called by CANVAS' draw method) if the layer's visibility is set to true.
Syntax
layer.draw( );
Returns
- (object) Layer instance
Layer Method: promote
Promotes the layer in the stack, calls CANVAS.layers.promote( this.options.id ).
Syntax
layer.promote( );
Returns
- (object) Layer instance
Layer Method: demote
Demotes the layer in the stack, calls CANVAS.layers.demote( this.options.id ).
Syntax
layer.demote( );
Returns
- (object) Layer instance
Layer Method: swap
Swaps the layer's position with another layer's position in the stack, calls CANVAS.layers.swap( this.options.id, targetId ).
Syntax
layer.demote( targetId );
Arguments
- targetId - (string) the id of the layer to swap the position with.
Returns
- (object) Layer instance