Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
166 views
in Technique[技术] by (71.8m points)

javascript - What are the differences between group and layer in KineticJs

I am developing a HTML5 web application using KineticJS. I read that in KineticJS there are grouping and layering. As far as I know there are no differences between them. Can you tell me the differences?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The basic difference: Groups are containers while Layers are separators.

Group:

  • A group is a container for shaped objects inside a layer.
  • For example, a group might contain both a circle and a rectangle.
  • A group can be manipulated and all elements within that group are similarly manipulated.
  • For example, dragging a group will simultaneously drag a circle and rectangle contained in that group.

Layer:

  • Layers are actually separate canvas elements that are stacked atop each other.
  • This is similar to the way layers work in Photoshop and Illustrator.
  • Multiple layers are visible simultaneously.
  • If objects from different layers overlap, the topmost object displays fully (like z-indexing).

Groups are used to contain multiple items so they can be manipulated as a group--like putting circles and lines into a group to create a "stickman". Moving the group will move all the pieces of the stickman.

Layers are used to separate different items--like having a background layer that doesn't change and a top layer where animation is occurring.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...