Global Scope
When code is executed as PaperScript, the script’s scope is populated with all fields of the currently active PaperScope object, which within the script appear to be global.
In a JavaScript context, only the paper variable is added to the global scope, referencing the currently active PaperScope object, through which all properties and Paper.js classes can be accessed.
Properties
paperA reference to the currently active
PaperScopeobject.Type:
PaperScope
Global PaperScript Properties
projectThe project for which the PaperScript is executed.
Note that when working with multiple projects, this does not necessarily reflect the currently active project. For this, use
paperScope.projectinstead.Type:
Project
projectsThe list of all open projects within the current Paper.js context.
Type:
Array of
Projectobjects
viewThe reference to the project’s view.
Note that when working with multiple projects, this does not necessarily reflect the view of the currently active project. For this, use
paperScope.viewinstead.Read only.
Type:
View
toolThe reference to the tool object which is automatically created when global tool event handlers are defined.
Note that when working with multiple tools, this does not necessarily reflect the currently active tool. For this, use
paperScope.toolinstead.Type:
Tool
toolsThe list of available tools.
Type:
Array of
Toolobjects
PaperScript View Event Handlers
onFrameA global reference to the
view.onFramehandler function.Type:
Function
onResizeA reference to the
view.onResizehandler function.Type:
Function
PaperScript Tool Event Handlers
onMouseDownA reference to the
tool.onMouseDownhandler function.Type:
Function
onMouseDragA reference to the
tool.onMouseDraghandler function.Type:
Function
onMouseMoveA reference to the
tool.onMouseMovehandler function.Type:
Function
onMouseUpA reference to the
tool.onMouseUphandler function.Type:
Function
Keyboard Event Handlers (for PaperScript)
onKeyDownA reference to the
tool.onKeyDownhandler function.Type:
Function
onKeyUpA reference to the
tool.onKeyUphandler function.Type:
Function
Last updated
Was this helpful?