Static Object: CANVAS

This object is used to interact with the Canvas, layers, threads and items. This object has no constructor and can only exist once per document.

CANVAS Method: init

Initialize the Canvas object. Call only once.

Syntax

CANVAS.init( options );

Arguments

  1. options - (object, optional) An object with the options for the Canvas.

Options

Returns

Notes

Setting cacheCtxPos to false will call Element.getPosition every time the mouse is moved over the canvas (mousemove is used to emulate mouseover and mouseout as well) and might eat some cpu. If your canvasElement is moved around the document and you want to update the position at certain points in time just do:

CANVAS.ctxPos = $(CANVAS.ctxEl).getPosition();

CANVAS Method: setDrag

Sets an item as the target for drag'n'drop operations.

Syntax

CANVAS.setDrag( item );

Arguments

  1. item - (object) CanvasItem instance

Returns

CANVAS Method: clearDrag

Clears the drag target.

Syntax

CANVAS.clearDrag( );

Returns

CANVAS Method: clear

Clears a specified rectangle or the whole canvas

Syntax

CANVAS.clear( [ rect ] );

Arguments

  1. rect - (array, optional) A simple rectangle: [x,y,width,height]. Will clear the whole canvas if left blank

Returns

CANVAS Method: draw

Draws all Layers that are stored in the local LayerHash.

Syntax

CANVAS.draw();

Returns

CANVAS Method: addThread

Stores a new thread in the threads-hash. CANVAS.threads can also be used with the common methods of Hash.

Syntax

CANVAS.addThread( thread );

Arguments

  1. thread - (object, required) New Thread

Returns

CANVAS Method: removeThread

Removes a thread from the threads-hash and calls the threads destroy-function.

Syntax

CANVAS.addThread( threadId );

Arguments

  1. thread id - (string, required) Id of the thread to remove.

Returns

  1. CANVAS
  2. LayerHash
  3. Layer
  4. CanvasItem
  5. Thread
  6. Cmorph