Developer API Documentation

This section contains documentation on Pencil’s internal API for Pencil’s developers.


class CollectionManager()

A namespace responsible for loading and unloading Stencil Collections.


The Controller() is responsible for managing the Document & its Pages. It is usually accesed via the global Pencil object.

class Controller(win)
  • win – The window the controller should manipulate.

The Element containing the application’s main display window.

The Controller object contains methods for creating new Documents/Pages, saving/loading Documents & moving/removing/duplicating Pages.


Initializes a global Pencil namespace & sets up event listeners on boot.

class Pencil()

The Pencil namespace contains attributes linked to the application’s Controller, Rasterizer, etc. as well as various helper functions.


A Controller() initialized from the XUL window.

  • id – The id of a DocumentExporter.

The requested DocumentExporter or null if a matching DocumentExporter cannot be found.

  • v – boolean; currently only as false; determines state of the format painter function.


Side Effect: If passed value v is false, it deactivates the format painter tool (used for copying formats of stencils on canvas) Side Effect: If passed value v is false, it removes the painter class from all canvas (“pages” in the GUI) if passed value v is false.

Called on click on stencils on canvas or if the toolbarFormatPainterCommand button is clicked.


Activates & deactivates commands via the Pencil._enableCommand() function along with the ids of the <command> XUL Elements from mainWindow.xul.

Called e.g. if an element is selected in order to provide applicable commands.

Whether a command is activated or deactivated depends on the state of the application(if a document has been created, if there is an active canvas element, etc.) and the active element (e.g. a selected stencil)

Pencil._enableCommand(name, condition)
  • name (string) – An id of a <command> XUL Element.
  • condition (boolean) – Determines whether the command is activated or deactivated. A value of true activates the command.