This package is not yet finished.
DrawingJS
DrawingJS will offer an easy API to create images and animations with JavaScript.
Drawing
Constructor (canvasID, width, height)
-
canvasID
- The id of the <canvas> element that the drawing should be in. Throws an error if no element with the id exists, or if it is not a <canvas> element.
-
width
- The width of the drawing in pixels. Throws an error if 0 or less.
-
height
- The height of the drawing in pixels. Throws an error if 0 or less.
Properties
Properties in bold are those that are usually okay to change from the outside, and will be (without much trouble) respected when you next call draw(). Other properties should only be changed by those who know what they're doing.
-
canvas
- The canvas element of the drawing.
-
context
- The context of the canvas element of the drawing.
-
width
- The width of the drawing in pixels.
-
height
- The height of the drawing in pixels.
Methods
addElement(element)
-
element
- The element to be added.
Adds element to the drawing. Note that the elements will not be drawn immediately, only once draw() is called. Elements are drawn in the order addElement() was called.
draw()
Starts drawing the elements that have been added to the drawing.
Rectangle
Constructor(options)
-
options
- An object containing the options. The default is a 10x10 rectangle in the upper left corner, any options here will override that. Supported options are:
- size
- Either an object of type Size, or an object containing width and height integers.
- size
- An object containing the options. The default is a 10x10 rectangle in the upper left corner, any options here will override that. Supported options are: