What are the differences between group and layer in KineticJs

I am developing an HTML5 web application using KineticJS. I read that in KineticJS there is a grouping and bundle. As far as I know, there is no difference between them. Can you talk about the differences?

+4
source share
2 answers

The main difference: Groups are containers, and layers are separators.

Group

  • A group is a container for molded objects within a layer.
  • For example, a group can contain both a circle and a rectangle.
  • A group can be manipulated, and all elements within this group are managed in the same way.
  • For example, dragging a group will simultaneously drag the circle and rectangle contained in that group.

Layer:

  • Layers are actually separate canvas elements that are stacked on top of each other.
  • This is similar to how layers work in Photoshop and Illustrator.
  • Multiple layers are displayed simultaneously.
  • If objects from different layers overlap, the top object is displayed completely (for example, z-indexing).

Groups are used to place several elements, so they can be manipulated as a group - for example, put circles and lines in a group to create a "stickman". Moving a group will move all stickman pieces.

Layers are used to separate different elements - for example, the presence of a background layer that does not change, and the top layer where the animation takes place.

+12
source

Groups are simply a group of elements or objects that can be stacked in any way, usually inside a layer .

Layers are different areas of the canvas that can be added on top of each other on the stage.

0
source

Source: https://habr.com/ru/post/1491273/


All Articles