KineticJs中的组和层之间有什么区别? [英] What are the differences between group and layer in KineticJs

查看:113
本文介绍了KineticJs中的组和层之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用KineticJS开发HTML5 Web应用程序。我读到在KineticJS中有分组和分层。据我所知,他们之间没有区别。你可以告诉我区别吗?

解决方案

基本区别:组是容器,而图层是分隔符。



Group:


  • 组是一个容器,层。例如,一个组可能同时包含一个圆形和一个矩形。

  • 可以操作一个组,并且该组中的所有元素都被类似地操纵。

  • 例如,拖动一个组会同时拖动该组中包含的一个圆形和矩形。


Layer:


  • 图层实际上是单独堆叠在一起的画布元素。

  • 这与图层在Photoshop和Illustrator中的工作方式类似。

  • 多个图层可同时显示。

  • 如果来自不同图层的对象重叠,最上面的对象将完全显示(如z-indexing)。



组用于包含多个项目,因此可以将它们作为一个组进行操作 - 例如将圆和线放入组中以创建一个火柴人。移动该组将移动该火柴人的所有部分。



图层用于分隔不同的项目 - 如具有不变的背景图层和顶层动画正在发生。


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?

解决方案

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.

这篇关于KineticJs中的组和层之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆