paper.js/src/item/Group.js

44 lines
912 B
JavaScript
Raw Normal View History

Group = Item.extend({
2011-02-16 16:06:24 -05:00
beans: true,
initialize: function(items) {
this.base();
2011-02-11 12:37:36 -05:00
this.children = [];
if (items) {
for (var i = 0, l = items.length; i < l; i++) {
this.appendTop(items[i]);
}
}
2011-02-11 12:37:36 -05:00
this.clipped = false;
},
draw: function(ctx) {
for (var i = 0, l = this.children.length; i < l; i++) {
this.children[i].draw(ctx);
2011-02-11 12:37:36 -05:00
}
},
/**
* Specifies whether the group item is to be clipped.
* When setting to true, the first child in the group is automatically
* defined as the clipping mask.
*
* Sample code:
* <code>
* var group = new Group();
* group.appendChild(path);
* group.clipped = true;
* </code>
* @return {@true if the group item is to be clipped}
*/
isClipped: function() {
return this._clipped;
2011-02-11 12:37:36 -05:00
},
setClipped: function(clipped) {
this._clipped = clipped;
2011-02-11 12:37:36 -05:00
var child = this.firstChild;
if (child)
2011-02-11 12:37:36 -05:00
child.setClipMask(clipped);
}
});