Here is an example adapted from http://paperjs.org/examples/boolean-operations/ : http://sketch.paperjs.org
Since the rectangle cuts all the way through the square, the square.subtract(pole)
operation results in a single path containing two closed regions. Is there a way in Paper.js to separate them into 2 paths I can change independently?
The result of .subtract
actually is a CompoundPath. It doesn't appear to be in the example above because setting fill color on one of the children of a compound path doesn't work; the style of a CompoundPath is shared by all children.
The subpaths can be accessed via .children
and changed independently when they are taken out of the compound path. See example.