Class Painter
The paint tool application object.
Defined in: index.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Painter()
|
Field Attributes | Field Name and Description |
---|---|
Holds the buffer canvas and context references.
|
|
<private> |
Holds references to important DOM elements.
|
<private> <inner> |
Holds the keyboard event listener object.
|
Holds the current layer ID, canvas and context references.
|
|
The instance of the active tool object.
|
Method Attributes | Method Name and Description |
---|---|
<private> <inner> |
ev_canvas(ev)
The Canvas event handler.
|
<private> <inner> |
ev_keydown(ev)
The global
keydown event handler. |
<private> <inner> |
The event handler for any changes made to the tool selector.
|
<private> <inner> |
init()
Initialize the paint application.
|
This method draws the buffer canvas on top of the current image layer,
after which the buffer is cleared.
|
|
toolActivate(id)
Activate a drawing tool by ID.
|
- See:
- lib.dom.KeyboardEventListener The class dealing with the cross-browser differences in the DOM keyboard events.
- See:
- PainterConfig.tool_default holds the ID of the tool which is activated when the application loads.
This method determines the mouse position relative to the canvas
element, after which it invokes the method of the currently active tool
with the same name as the current event type. For example, for the
mousedown
event the tool.mousedown()
method is invoked.
The mouse coordinates are added to the ev DOM Event object: ev.x_ and ev.y_.
- Parameters:
- {Event} ev
- The DOM Event object.
keydown
event handler. This makes all the keyboard
shortcuts work in the web application.
This method determines the key the user pressed, based on the ev DOM Event object, taking into consideration any browser differences.
In PainterConfig.keys one can setup the keyboard shortcuts. If the keyboard combination is found in that list, then the associated tool is activated.
- Parameters:
- {Event} ev
- The DOM Event object.
- See:
- PainterConfig.keys The keyboard shortcuts configuration.
- lib.dom.KeyboardEventListener The class dealing with the cross-browser differences in the DOM keyboard events.
- See:
- Painter#toolActivate The method which does the actual drawing tool activation.
The id provided must be available in the global PaintTools object.
- Parameters:
- {String} id
- The ID of the drawing tool to be activated.
- Returns:
- {Boolean} True if the tool has been activated, or false if not.
- See:
- PaintTools The object holding all the drawing tools.