paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.5k stars 1.23k forks source link

Feature: Layer activate method should return previously active layer #1035

Open ktsuttlemyre opened 8 years ago

ktsuttlemyre commented 8 years ago

The Layer activate() currently does not return anything. I found that creating clones, uniting, and other methods create a lot of artifacts. I decided to put all these on a layer that I delete after I get my final shape. I didn't like this at first but now I do since I can associate it with a debug flag to toggle visibility of it. Anyway, I often need to switch back and forth between my debug layer and the user's selected layer in order to make sure my artifacts are not seen in production. This could be greatly simplified by just returning the previous activeLayer from an activate() call

lehni commented 8 years ago

An interesting suggestion for sure. I'll consider it. We will have to figure out how to tackle chaining first though, as discussed here #605

Regarding the artifacts, those happen because any boolean operation on items that are in the scene graph will insert the results into the scene graph again. If you don't want that, the easiest way to handle the original items right now is by removing them from / not inserting them into the scene graph before performing the operation.

I am considering an options object on each boolean operation, with one option being options.insert which can be set to false. This would allow that behavior even on items that are themselves inserted: #1072