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
- options - (object, optional) An object with the options for the Canvas.
Options
- canvasElement - (HTMLDomElement or String) HTML Canvas element to use, must work with $()
- enableMouse - (bool, optional) Whether or not to provide misc mouse events to items
- cacheCtxPos - (bool, defaults to true) Should CANVAS.ctxEl's position be calculated on each mouse-event?
Returns
- (object) - this (CANVAS object)
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
- item - (object) CanvasItem instance
Returns
- (null)
CANVAS Method: clearDrag
Clears the drag target.
Syntax
CANVAS.clearDrag( );
Returns
- (null)
CANVAS Method: clear
Clears a specified rectangle or the whole canvas
Syntax
CANVAS.clear( [ rect ] );
Arguments
- rect - (array, optional) A simple rectangle: [x,y,width,height]. Will clear the whole canvas if left blank
Returns
- (object) this (CANVAS object)
CANVAS Method: draw
Draws all Layers that are stored in the local LayerHash.
Syntax
CANVAS.draw();
Returns
- (object) this (CANVAS object)
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
- thread - (object, required) New Thread
Returns
- (object) thread (Thread instance)
CANVAS Method: removeThread
Removes a thread from the threads-hash and calls the threads destroy-function.
Syntax
CANVAS.addThread( threadId );
Arguments
- thread id - (string, required) Id of the thread to remove.
Returns
- (null)