A Project object in Paper.js is what usually is referred to as the document: The top level object that holds all the items contained in the scene graph. As the term document is already taken in the browser context, it is called Project.
Projects allow the manipulation of the styles that are applied to all newly created items, give access to the selected items, and will in future versions offer ways to query for items in the scene graph defining specific requirements, and means to persist and load from different formats, such as SVG and PDF.
The currently active project can be accessed through the paperScope.project variable.
An array of all open projects is accessible through the paperScope.projects variable.
Creates a Paper.js project containing one empty Layer, referenced by project.activeLayer.
Note that when working with PaperScript, a project is automatically created for us and the paperScope.project variable points to it.
The currently active path style. All selected items and newly created items will be styled with this style.
Example
Example
The layer which is currently active. New items will be created on this layer by default.
Read only.
Activates this project, so all newly created items will be placed in it.
Clears the project by removing all project.layers and project.symbols.
Checks whether the project has any content or not.
Removes this project from the paperScope.projects list, and also removes its view, if one was defined.
Selects all items in the project.
Deselects all selected items in the project.
Perform a hit-test on the items contained within the project at the location of the specified point.
The options object allows you to control the specifics of the hit-test and may contain a combination of the following values:
Fetch items contained within the project whose properties match the criteria in the specified object.
Extended matching is possible by providing a compare function or regular expression. Matching points, colors only work as a comparison of the full object, not partial matching (e.g. only providing the x- coordinate to match all points with that x-value). Partial matching does work for item.data.
Matching items against a rectangular area is also possible, by setting either match.inside or match.overlapping to a rectangle describing the area in which the items either have to be fully or partly contained.
See also: item.matches(match), item.getItems(match)
Example — Fetch all selected path items:
Example — Fetch all items with a specific fill color:
Example — Fetch items at a specific position:
Example — Fetch items using a comparing function:
Example — Fetch items using a comparing function (2):
Example — Match (nested) properties of the data property:
Example — Match strings using regular expressions:
Fetch the first item contained within the project whose properties match the criteria in the specified object.
Extended matching is possible by providing a compare function or regular expression. Matching points, colors only work as a comparison of the full object, not partial matching (e.g. only providing the x- coordinate to match all points with that x-value). Partial matching does work for item.data.
See getItems(match) for a selection of illustrated examples.
Exports (serializes) the project with all its layers and child items to a JSON data object or string.
Imports (deserializes) the stored JSON data into the project.
Note that the project is not cleared first. You can call project.clear() to do so.
Exports the project with all its layers and child items as an SVG DOM, all contained in one top level SVG group node.
Converts the provided SVG content into Paper.js items and adds them to the active layer of this project.
Note that the project is not cleared first. You can call project.clear() to do so.
Imports the provided external SVG file, converts it into Paper.js items and adds them to the active layer of this project.
Note that the project is not cleared first. You can call project.clear() to do so.
Copyright © 2011 Jürg Lehni & Jonathan Puckey. All Rights Reserved.