I am hoping it is possible to create, say, a Paper.Path
object that is not attached to a scope. The reason I need to do this is because I have a few parser classes who's job it is to generate geometry from a gerber file, they should not have any influence over the PaperScope
's canvas
. A simple separation of concerns.
For example: (this code won't work)
import paper, {Path, Point} from 'paperjs';
let path = new Path([new Point(100, 100), new Point(200, -50)]);
paper.addPath(path); <- this doesn't exist but you get the point.
There are no obvious ways to go about this, and the paperjs docs seem to tout this "clever scoping" as a feature, but it's really been a pain to work with...
You can setup Paper.js so that it doesn't insert newly created in the scene by default. You have to set paper.settings.insertItems = false
when initializing your app (see the documentation).
If you want some items to be part of the scene and other not, you can have a finer control over whether they are inserted or not by passing an insert: true/false
parameter to the constructor.
Here is a sketch demonstrating this behavior.
// Switch this to true to see the difference.
const INSERT = false;
const circle = new Path.Circle({
center: view.center,
radius: 50,
fillColor: 'orange',
insert: INSERT
})