-1

Would you please advice where I could find explanation about Group({insert:true}) option as I could not find it in reference? How does this option work and if someone had made that example he should be able to read about it somewhere. Thanks.

  • http://paperjs.org/reference/group/#group-object – Dylan May 29 '19 at 19:02
  • There are no “insert” property for Group object by the provided link. – Alexey Polyakov May 29 '19 at 21:47
  • You arent using an "insert" property, you are putting `{insert:true}` into the constructor of Group. `{insert:true}` is a JavaScript Object, thus the Group constructor takes that as an entire object. – Dylan May 30 '19 at 14:17
  • ok, but I didn't find what does it mean. As I met it in one example is it possible to find detailed explanation? The only one thing I have found was in boolean operations with paths and it was about inserting to DOM. Could someone explain if it means the same when this option should be used and how oes it impact on result? Thanks. – Alexey Polyakov May 30 '19 at 22:35
  • You should take a look at this: http://embed.plnkr.co/0A6Ag5/ If you look through it they use "{insert:true}" as well. Maybe you can figure it out from that. I'm not as familiar with paperjs. – Dylan May 31 '19 at 15:27

1 Answers1

1

This item constructor option is an internal API that doesn't really have a public use case, this is why you didn't find it in the documentation.
It is mainly used for internal operations and testing purpose.
It is true by default and if you set it to false, the consequence is that the created item will not be inserted into the scene graph, meaning you won't see it on the screen.

Look at this sketch for a demonstration.

// This item will be inserted as a child of the active layer.
const itemInserted = new Path.Circle({
    center: view.center - 50,
    radius: 50,
    fillColor: 'orange'
});

// This item will not be inserted in the scene graph.
const itemNotInserted = new Path.Circle({
    center: view.center + 50,
    radius: 50,
    fillColor: 'blue',
    insert: false
});
sasensi
  • 4,610
  • 10
  • 35
  • Thanks. Is there any performance difference if I insert to DOM a group and create two thousands rectangles inside it and then do some measurements between them or it is better not to insert them if they used only for measurements. There is also “visible” property I also could use so would like to know the performance impact if not inserting to DOM. – Alexey Polyakov Jun 07 '19 at 03:02
  • Yes, if it is for measurement only, you should definitely avoid inserting them in the scene. About not inserted vs not visible, I would say that not inserted should be slightly faster but I guess that you have to benchmark it to know what is better for your specific use case. – sasensi Jun 07 '19 at 07:44