Class Index | File Index

Classes


Class PaintWeb

The PaintWeb application object.
Defined in: paintweb.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
PaintWeb(win, doc)
Field Summary
Field Attributes Field Name and Description
<static>  
PaintWeb.baseFolder
PaintWeb base folder.
 
Holds the buffer canvas and context references.
 
PaintWeb build date (YYYYMMDD).
 
Image in the clipboard.
 
Holds all the PaintWeb commands.
 
Holds all the PaintWeb configuration.
<private>  
doc
The document element PaintWeb is working with.
<constant>  
Element node type constant.
<private>  
Holds references to DOM elements.
 
Custom application events object.
 
Holds all the PaintWeb extensions.
 
gui
The graphical user interface object instance.
<private>  
The image history.
 
Holds image information: width, height, zoom and more.
<static> <constant>  
PaintWeb.INIT_DONE
Application initialization completed successfully.
<static> <constant>  
PaintWeb.INIT_ERROR
Application initialization failed.
<static> <constant>  
PaintWeb.INIT_NOT_STARTED
Application initialization not started.
<static> <constant>  
PaintWeb.INIT_STARTED
Application initialization started.
 
Application initialization state.
<private> <inner>  
Holds the keyboard event listener object.
 
Holds all language strings used within PaintWeb.
 
Holds the current layer ID, canvas and context references.
<private>  
Holds the last recorded mouse coordinates and the button state (if it's down or not).
 
Resolution information.
 
Tells if the current tool allows the drawing of shadows.
 
Tells if the browser supports the Canvas Shadows API.
<private>  
List of Canvas context properties to save and restore.
<private> <inner>  
Holds temporary state information during PaintWeb initialization.
 
The instance of the active tool object.
 
UID
Unique ID for the current PaintWeb instance.
 
PaintWeb version.
<private>  
win
The window object PaintWeb is working with.
Method Summary
Method Attributes Method Name and Description
 
Paste the current clipboard image.
 
commandRegister(id, func)
Register a new command in PaintWeb.
 
Unregister a command from PaintWeb.
<private>  
The configChange application event handler.
<private>  
Asynchronously load the configuration file.
<private>  
The configuration reader.
 
Destroy a PaintWeb instance.
<private>  
The Canvas events handler.
<private>  
The global keyboard events handler.
<private>  
This is the keypress event handler for inputs of type=number.
<private>  
The load event handler for each extension script.
 
Register a new extension into PaintWeb.
 
Unregister an extension from PaintWeb.
<private>  
Load th PaintWeb GUI.
<private>  
The GUI markup reader.
<private>  
The load event handler for the PaintWeb GUI script.
 
Add the current image layer to the history.
 
Jump to any ImageData/position in the history.
 
Perform action redo.
<private>  
Clear the image history.
 
Perform action undo.
 
Clear the image.
 
imageCrop(cropX, cropY, cropWidth, cropHeight)
Crop the image.
 
imageLoad(importImage)
Load an image.
 
imageSave(type)
Save the image.
<private>  
The imageSaveResult application event handler.
 
Zoom into the image.
 
Zoom out of the image.
 
Reset the image zoom level to normal.
 
imageZoomTo(level)
Change the image zoom level.
 
init(handler)
Initialize PaintWeb.
<private>  
Initialize the Canvas elements.
<private>  
Initialize the PaintWeb commands.
<private>  
Initialization procedure which runs after the configuration, language and GUI files have loaded.
<private>  
Initialize the Canvas buffer context.
<private>  
initError(msg)
Report an initialization error.
<private>  
Load all the extensions.
<private>  
Load all the configured drawing tools.
<private>  
The load event handler for the JSON library script.
<private>  
Asynchronously load the language file.
<private>  
langReady(xhr)
The language file reader.
 
Update the current image layer by moving the pixels from the buffer onto the layer.
<private> <inner>  
PaintWeb pre-initialization code.
<private>  
The load event handler for the PaintWeb library script.
 
scriptLoad(url, handler)
Load a script into the document.
 
Select all the pixels.
 
Copy the available selection.
 
Cut the available selection.
 
Allow shadows.
 
Disallow shadows.
 
stateRestore(context, stateObj)
Restore the state of a Canvas context.
 
stateSave(context)
Save the state of a Canvas context.
 
styleLoad(id, url, media, handler)
Insert a stylesheet into the document.
 
Swap the fill and stroke styles.
 
toolActivate(id, ev)
Activate a drawing tool by ID.
<private>  
The load event handler for each tool script.
 
Register a new drawing tool into PaintWeb.
 
toolSnapXY(x, y)
Perform horizontal/vertical line snapping.
 
Unregister a drawing tool from PaintWeb.
 
 
Update the canvas scaling.
Class Detail
PaintWeb(win, doc)
Parameters:
{Window} win Optional, Default: window
The window object to use.
{Document} doc Optional, Default: document
The document object to use.
Field Detail
<static> {String} PaintWeb.baseFolder
PaintWeb base folder. This is determined automatically when the PaintWeb script is added in a page.

{Object} buffer
Holds the buffer canvas and context references.

{Number} build
PaintWeb build date (YYYYMMDD).

{ImageData} clipboard
Image in the clipboard. This is used when some selection is copy/pasted.

{Object} commands
Holds all the PaintWeb commands. Each property in this object must reference a simple function which can be executed by keyboard shortcuts and/or GUI elements.
See:
PaintWeb#commandRegister Register a new command.
PaintWeb#commandUnregister Unregister a command.

{Object} config
Holds all the PaintWeb configuration.

<private> {Document} doc
The document element PaintWeb is working with.
Default Value:
document

<constant> {Number} ELEMENT_NODE
Element node type constant.

<private> {Object} elems
Holds references to DOM elements.

{pwlib.appEvents} events
Custom application events object.

{Object} extensions
Holds all the PaintWeb extensions.
See:
PaintWeb#extensionRegister Register a new extension.
PaintWeb#extensionUnregister Unregister an extension.
PaintWeb.config.extensions Holds the list of extensions to be loaded automatically when PaintWeb is initialized.

{pwlib.gui} gui
The graphical user interface object instance.

<private> {Object} history
The image history.

{Object} image
Holds image information: width, height, zoom and more.

<static> <constant> PaintWeb.INIT_DONE
Application initialization completed successfully.

<static> <constant> PaintWeb.INIT_ERROR
Application initialization failed.

<static> <constant> PaintWeb.INIT_NOT_STARTED
Application initialization not started.

<static> <constant> PaintWeb.INIT_STARTED
Application initialization started.

{Number} initialized
Application initialization state. This property can be in one of the following states:
Default Value:
PaintWeb.INIT_NOT_STARTED

<private> <inner> {pwlib.dom.KeyboardEventListener} kbListener_
Holds the keyboard event listener object.
See:
pwlib.dom.KeyboardEventListener The class dealing with the cross-browser differences in the DOM keyboard events.

lang
Holds all language strings used within PaintWeb.

{Object} layer
Holds the current layer ID, canvas and context references.

<private> {Object} mouse
Holds the last recorded mouse coordinates and the button state (if it's down or not).

{Object} resolution
Resolution information.

{Boolean} shadowAllowed
Tells if the current tool allows the drawing of shadows.
Default Value:
true

{Boolean} shadowSupported
Tells if the browser supports the Canvas Shadows API.
Default Value:
true

<private> {Array} stateProperties
List of Canvas context properties to save and restore.

When the Canvas is resized the state is lost. Using context.save/restore state does work only in Opera. In Firefox/Gecko and WebKit saved states are lost after resize, so there's no state to restore. As such, PaintWeb has its own simple state save/restore mechanism. The property values are saved into a JavaScript object.

See:
PaintWeb#stateSave to save the canvas context state.
PaintWeb#stateRestore to restore a canvas context state.

<private> <inner> {Object} temp_
Holds temporary state information during PaintWeb initialization.

{Object} tool
The instance of the active tool object.
See:
PaintWeb.config.toolDefault holds the ID of the tool which is activated when the application loads.
PaintWeb#toolActivate Activate a drawing tool by ID.
PaintWeb#toolRegister Register a new drawing tool.
PaintWeb#toolUnregister Unregister a drawing tool.
pwlib.tools holds the drawing tools.

{Number} UID
Unique ID for the current PaintWeb instance.

{Number} version
PaintWeb version.

<private> {Window} win
The window object PaintWeb is working with.
Default Value:
window
Method Detail
{Boolean} clipboardPaste(ev)
Paste the current clipboard image. This only works when some ImageData is available in PaintWeb#clipboard.
Parameters:
{Event} ev Optional
The DOM Event object which generated the request.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
The command implementation.

{Boolean} commandRegister(id, func)
Register a new command in PaintWeb. Commands are simple function objects which can be invoked by keyboard shortcuts or by GUI elements.

Once the command is successfully registered, this method dispatches the pwlib.appEvent.commandRegister application event.

Parameters:
{String} id
The ID of the new command.
{Function} func
The command function.
Returns:
{Boolean} True if the command was successfully registered, or false if not.
See:
PaintWeb#commandUnregister allows you to unregister commands.
PaintWeb#commands Holds all the registered commands.

{Boolean} commandUnregister(id)
Unregister a command from PaintWeb.

Before the command is unregistered, this method dispatches the pwlib.appEvent.commandUnregister application event.

Parameters:
{String} id
The ID of the command you want to unregister.
Returns:
{Boolean} True if the command was removed successfully, or false if not.
See:
PaintWeb#commandRegister allows you to register new commands.
PaintWeb#commands Holds all the registered commands.

<private> configChangeHandler(ev)
The configChange application event handler. This method updates the Canvas context properties depending on which configuration property changed.
Parameters:
{pwlib.appEvent.configChange} ev
The application event object.

<private> configLoad()
Asynchronously load the configuration file. This method issues an XMLHttpRequest to load the JSON file.
See:
PaintWeb.config.configFile The configuration file.
pwlib.xhrLoad The library function being used for creating the XMLHttpRequest object.

<private> configReady(xhr)
The configuration reader. This is the event handler for the XMLHttpRequest object, for the onreadystatechange event.
Parameters:
{XMLHttpRequest} xhr
The XMLHttpRequest object being handled.
See:
PaintWeb#configLoad The method which issues the XMLHttpRequest request for loading the configuration file.

destroy()
Destroy a PaintWeb instance. This method allows you to unload a PaintWeb instance. Extensions, tools and commands are unregistered, and the GUI elements are removed.

The scripts and styles loaded are not removed, since they might be used by other PaintWeb instances.

The pwlib.appEvent.appDestroy application event is dispatched before the current instance is destroyed.


<private> {Boolean} ev_canvas(ev)
The Canvas events handler.

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 stored in the PaintWeb#mouse object. These properties take into account the current zoom level and the image scroll.

Parameters:
{Event} ev
The DOM Event object.
Returns:
{Boolean} True if the tool event handler executed, or false otherwise.

<private> ev_keyboard(ev)
The global keyboard events 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. Two new properties are added to the ev object:

In PaintWeb.config.keys one can setup the keyboard shortcuts. If the keyboard combination is found in that list, then the associated tool is activated.

Note: this method includes some work-around for making the image zoom keys work well both in Opera and Firefox.

Parameters:
{Event} ev
The DOM Event object.
See:
PaintWeb.config.keys The keyboard shortcuts configuration.
pwlib.dom.KeyboardEventListener The class dealing with the cross-browser differences in the DOM keyboard events.

<private> ev_numberInput(ev)
This is the keypress event handler for inputs of type=number. This function only handles cases when the key is Up or Down. For the Up key the input value is increased, and for the Down the value is decreased.
Parameters:
{Event} ev
The DOM Event object.
See:
PaintWeb#ev_keyboard

<private> extensionLoaded()
The load event handler for each extension script.

{Boolean} extensionRegister(id)
Register a new extension into PaintWeb.

If the extension object being constructed has the extensionRegister() method, then it will be invoked, allowing any custom extension registration code to run. If the method returns false, then the extension will not be registered.

Once the extension is successfully registered, this method dispatches the pwlib.appEvent.extensionRegister application event.

Parameters:
{String} id
The ID of the new extension. The extension object constructor must exist in pwlib.extensions.
Returns:
{Boolean} True if the extension was successfully registered, or false if not.
See:
PaintWeb#extensionUnregister allows you to unregister extensions.
PaintWeb#extensions Holds all the instances of registered extensions.
pwlib.extensions Holds all the extension classes.

{Boolean} extensionUnregister(id)
Unregister an extension from PaintWeb.

If the extension object being destructed has the extensionUnregister() method, then it will be invoked, allowing any custom extension removal code to run.

Before the extension is unregistered, this method dispatches the pwlib.appEvent.extensionUnregister application event.

Parameters:
{String} id
The ID of the extension object you want to unregister.
Returns:
{Boolean} True if the extension was removed, or false if it does not exist or some error occurred.
See:
PaintWeb#extensionRegister allows you to register new extensions.
PaintWeb#extensions Holds all the instances of registered extensions.
pwlib.extensions Holds all the extension classes.

<private> guiLoad()
Load th PaintWeb GUI. This method loads the GUI markup file, the stylesheet and the script.
See:
PaintWeb.config.guiStyle The interface style file.
PaintWeb.config.guiScript The interface script file.
pwlib.gui The interface object.

<private> guiMarkupReady(xhr)
The GUI markup reader. This is the event handler for the XMLHttpRequest object, for the onreadystatechange event.
Parameters:
{XMLHttpRequest} xhr
The XMLHttpRequest object being handled.
See:
PaintWeb#guiScriptReady The method which issues the XMLHttpRequest request for loading the interface markup file.

<private> guiScriptReady()
The load event handler for the PaintWeb GUI script. This method creates an instance of the GUI object that just loaded and starts loading the GUI markup.
See:
PaintWeb.config.guiScript The interface script file.
PaintWeb.config.guiMarkup The interface markup file.
pwlib.gui The interface object.
pwlib.xhrLoad The library function being used for creating the XMLHttpRequest object.

{Boolean} historyAdd()
Add the current image layer to the history.

Once the history state has been updated, this method dispatches the pwlib.appEvent.historyUpdate event.

Returns:
{Boolean} True if the operation was successful, or false if not.

{Boolean} historyGoto(pos)
Jump to any ImageData/position in the history.

Once the history state has been updated, this method dispatches the pwlib.appEvent.historyUpdate event.

Parameters:
{Number|String} pos
The history position to jump to.

If the value is a number, then it must point to an existing index in the PaintWeb#history.states array.

If the value is a string, it must be "undo" or "redo".

Returns:
{Boolean} True if the operation was successful, or false if not.

{Boolean} historyRedo()
Perform action redo.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
PaintWeb#historyGoto The method invoked by this command.

<private> historyReset()
Clear the image history.

This method dispatches the pwlib.appEvent.historyUpdate event.


{Boolean} historyUndo()
Perform action undo.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
PaintWeb#historyGoto The method invoked by this command.

imageClear(ev)
Clear the image.
Parameters:
ev

{Boolean} imageCrop(cropX, cropY, cropWidth, cropHeight)
Crop the image.

The content of the image is retained only if the browser implements the getImageData and putImageData methods.

This method dispatches three application events: pwlib.appEvent.imageSizeChange, pwlib.appEvent.canvasSizeChange and pwlib.appEvent.imageCrop. The imageCrop event is dispatched before the image is cropped. The imageSizeChange and canvasSizeChange events are dispatched after the image is cropped.

Parameters:
{Number} cropX
Image cropping start position on the x-axis.
{Number} cropY
Image cropping start position on the y-axis.
{Number} cropWidth
Image crop width.
{Number} cropHeight
Image crop height.
Returns:
{Boolean} True if the image was cropped successfully, or false if not.

{Boolean} imageLoad(importImage)
Load an image. By loading an image the history is cleared and the Canvas dimensions are updated to fit the new image.

This method dispatches two application events: pwlib.appEvent.imageSizeChange and pwlib.appEvent.canvasSizeChange.

Parameters:
{Element} importImage
The image element you want to load into the Canvas.
Returns:
{Boolean} True if the operation was successful, or false if not.

{Boolean} imageSave(type)
Save the image.

This method dispatches the pwlib.appEvent.imageSave event.

Note: the "Save image" operation relies on integration extensions. A vanilla configuration of PaintWeb will simply open the the image in a new tab using a data: URL. You must have some event listener for the imageSave event and you must prevent the default action.

If the default action for the imageSave application event is not prevented, then this method will also dispatch the pwlib.appEvent.imageSaveResult application event.

Your event handler for the imageSave event must dispatch the imageSaveResult event.

Parameters:
{String} type Optional, Default: "auto"
Image MIME type. This tells the browser which format to use when saving the image. If the image format type is not supported, then the image is saved as PNG.

You can use the resulting data URL to check which is the actual image format.

When type is "auto" then PaintWeb checks the type of the image currently loaded (PaintWeb.config.imageLoad). If the format is recognized, then the same format is used to save the image.

Returns:
{Boolean} True if the operation was successful, or false if not.

<private> imageSaveResultHandler(ev)
The imageSaveResult application event handler. This method PaintWeb-related stuff: for example, the PaintWeb.image.modified flag is turned to false.
Parameters:
{pwlib.appEvent.imageSaveResult} ev
The application event object.
See:
The method which allows you to save the image.

{Boolean} imageZoomIn(ev)
Zoom into the image.
Parameters:
{mixed} ev
An event object which might have the shiftKey property. If the property evaluates to true, then the zoom level will increase twice more than normal.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
PaintWeb#imageZoomTo The method used for changing the zoom level.
PaintWeb.config.zoomStep The value used for increasing the zoom level.

{Boolean} imageZoomOut(ev)
Zoom out of the image.
Parameters:
{mixed} ev
An event object which might have the shiftKey property. If the property evaluates to true, then the zoom level will decrease twice more than normal.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
PaintWeb#imageZoomTo The method used for changing the zoom level.
PaintWeb.config.zoomStep The value used for decreasing the zoom level.

{Boolean} imageZoomReset(ev)
Reset the image zoom level to normal.
Parameters:
ev
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
PaintWeb#imageZoomTo The method used for changing the zoom level.

{Boolean} imageZoomTo(level)
Change the image zoom level.

This method dispatches the pwlib.appEvent.imageZoom application event before zooming the image. Once the image zoom is applied, the pwlib.appEvent.canvasSizeChange event is dispatched.

Parameters:
{Number|String} level
The level you want to zoom the image to.

If the value is a number, it must be a floating point positive number, where 0.5 means 50%, 1 means 100% (normal) zoom, 4 means 400% and so on.

If the value is a string it must be "+" or "-". This means that the zoom level will increase/decrease using the configured PaintWeb.config.zoomStep.

Returns:
{Boolean} True if the image zoom level changed successfully, or false if not.

{Boolean} init(handler)
Initialize PaintWeb.

This method is asynchronous, meaning that it will return much sooner before the application initialization is completed.

Parameters:
{Function} handler Optional
The appInit event handler. Your event handler will be invoked automatically when PaintWeb completes loading, or when an error occurs.
Returns:
{Boolean} True if the initialization has been started successfully, or false if not.

<private> {Boolean} initCanvas()
Initialize the Canvas elements. This method creates the elements and sets-up their dimensions.

The layer Canvas element will have the background rendered with the color from PaintWeb.config.backgroundColor.

If PaintWeb.config.imageLoad is defined, then the image element is inserted into the Canvas image.

All the Canvas event listeners are also attached to the buffer Canvas element.

Returns:
{Boolean} True if the initialization was successful, or false if not.
See:
PaintWeb#ev_canvas The global Canvas events handler.

<private> {Boolean} initCommands()
Initialize the PaintWeb commands.
Returns:
{Boolean} True if the initialization was successful, or false if not.

<private> initComplete()
Initialization procedure which runs after the configuration, language and GUI files have loaded.

This method dispatches the pwlib.appEvent.appInit event.

See:
pwlib.appEvent.appInit

<private> {Boolean} initContext()
Initialize the Canvas buffer context. This method updates the context properties to reflect the values defined in the PaintWeb configuration file.

Shadows support is also determined. The PaintWeb#shadowSupported value is updated accordingly.

Returns:
{Boolean} True if the initialization was successful, or false if not.

<private> initError(msg)
Report an initialization error.

This method dispatches the pwlib.appEvent.appInit event.

Parameters:
{String} msg
The error message.
See:
pwlib.appEvent.appInit

<private> initExtensions()
Load all the extensions.

<private> initTools()
Load all the configured drawing tools.

<private> jsonlibReady()
The load event handler for the JSON library script.

<private> langLoad()
Asynchronously load the language file. This method issues an XMLHttpRequest to load the JSON file.
See:
PaintWeb.config.lang The language you want for the PaintWeb user interface.
pwlib.xhrLoad The library function being used for creating the XMLHttpRequest object.

<private> langReady(xhr)
The language file reader. This is the event handler for the XMLHttpRequest object, for the onreadystatechange event.
Parameters:
{XMLHttpRequest} xhr
The XMLHttpRequest object being handled.
See:
PaintWeb#langLoad The method which issues the XMLHttpRequest request for loading the language file.

{Boolean} layerUpdate()
Update the current image layer by moving the pixels from the buffer onto the layer. This method also adds a point into the history.
Returns:
{Boolean} True if the operation was successful, or false if not.

<private> <inner> preInit()
PaintWeb pre-initialization code. This runs when the PaintWeb instance is constructed.

<private> pwlibReady()
The load event handler for the PaintWeb library script.

scriptLoad(url, handler)
Load a script into the document.
Parameters:
{String} url
The script URL you want to insert.
{Function} handler Optional
The load event handler you want.

{Boolean} selectAll(ev)
Select all the pixels. This activates the selection tool, and selects the entire image.
Parameters:
{Event} ev Optional
The DOM Event object which generated the request.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
The command implementation.

{Boolean} selectionCopy(ev)
Copy the available selection. This only works when the selection tool is active and when some selection is available.
Parameters:
{Event} ev Optional
The DOM Event object which generated the request.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
The command implementation.

{Boolean} selectionCut(ev)
Cut the available selection. This only works when the selection tool is active and when some selection is available.
Parameters:
{Event} ev Optional
The DOM Event object which generated the request.
Returns:
{Boolean} True if the operation was successful, or false if not.
See:
The command implementation.

shadowAllow()
Allow shadows. This method re-enabled shadow rendering, if it was enabled before shadows were disallowed.

The pwlib.appEvent.shadowAllow event is dispatched.


shadowDisallow()
Disallow shadows. This method disables shadow rendering, if it is enabled.

The pwlib.appEvent.shadowAllow event is dispatched.


{Boolean} stateRestore(context, stateObj)
Restore the state of a Canvas context.
Parameters:
{CanvasRenderingContext2D} context
The 2D context where you want to restore the state.
{Object} stateObj
The state object saved by the PaintWeb#stateSave method.
Returns:
{Boolean} True if the operation was successful, or false if not.

{Object} stateSave(context)
Save the state of a Canvas context.
Parameters:
{CanvasRenderingContext2D} context
The 2D context of the Canvas element you want to save the state.
Returns:
{Object} The object has all the state properties and values.

styleLoad(id, url, media, handler)
Insert a stylesheet into the document.
Parameters:
{String} id
The stylesheet ID. This is used to avoid inserting the same style in the document.
{String} url
The URL of the stylesheet you want to insert.
{String} media Optional, Default: 'screen, projection'
The media attribute.
{Function} handler Optional
The load event handler.

swapFillStroke()
Swap the fill and stroke styles. This is just like in Photoshop, if the user presses X, the fill/stroke colors are swapped.

This method dispatches the pwlib.appEvent.configChange event twice for each color (strokeStyle and fillStyle).


{Boolean} toolActivate(id, ev)
Activate a drawing tool by ID.

The id provided must be of an existing drawing tool, one that has been installed.

The ev argument is an optional DOM Event object which is useful when dealing with different types of tool activation, either by keyboard or by mouse events. Tool-specific code can implement different functionality based on events.

This method dispatches the pwlib.appEvent.toolPreactivate event before creating the new tool instance. Once the new tool is successfully activated, the pwlib.appEvent.toolActivate event is also dispatched.

Parameters:
{String} id
The ID of the drawing tool to be activated.
{Event} ev Optional
The DOM Event object.
Returns:
{Boolean} True if the tool has been activated, or false if not.
See:
PaintWeb#toolRegister Register a new drawing tool.
PaintWeb#toolUnregister Unregister a drawing tool.
pwlib.tools The object holding all the drawing tools.
pwlib.appEvent.toolPreactivate
pwlib.appEvent.toolActivate

<private> toolLoaded()
The load event handler for each tool script.

{Boolean} toolRegister(id)
Register a new drawing tool into PaintWeb.

This method dispatches the pwlib.appEvent.toolRegister application event.

Parameters:
{String} id
The ID of the new tool. The tool object must exist in pwlib.tools.
Returns:
{Boolean} True if the tool was successfully registered, or false if not.
See:
PaintWeb#toolUnregister allows you to unregister tools.
pwlib.tools Holds all the drawing tools.
pwlib.appEvent.toolRegister

toolSnapXY(x, y)
Perform horizontal/vertical line snapping. This method updates the mouse coordinates to "snap" with the given coordinates.
Parameters:
{Number} x
The x-axis location.
{Number} y
The y-axis location.

{Boolean} toolUnregister(id)
Unregister a drawing tool from PaintWeb.

This method dispatches the pwlib.appEvent.toolUnregister application event.

Parameters:
{String} id
The ID of the tool you want to unregister.
Returns:
{Boolean} True if the tool was unregistered, or false if it does not exist or some error occurred.
See:
PaintWeb#toolRegister allows you to register new drawing tools.
pwlib.tools Holds all the drawing tools.
pwlib.appEvent.toolUnregister

toString()

updateCanvasScaling()
Update the canvas scaling. This method determines the DPI and/or zoom level used by the browser to render the application. Based on these values, the canvas elements are scaled down to cancel any upscaling performed by the browser.

The pwlib.appEvent.canvasSizeChange application event is dispatched.


Documentation generated by JsDoc Toolkit 2.3.0 on Sat Jun 26 2010 21:56:59 GMT+0300 (EEST)