mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Add Group#getBounds().
This commit is contained in:
parent
52b69817a0
commit
7e404703c8
1 changed files with 18 additions and 0 deletions
|
@ -17,6 +17,24 @@ Group = Item.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getBounds: function() {
|
||||||
|
if(this.children.length) {
|
||||||
|
var rect = this.children[0].bounds;
|
||||||
|
var x1 = rect.x;
|
||||||
|
var y1 = rect.y;
|
||||||
|
var x2 = rect.x + rect.width;
|
||||||
|
var y2 = rect.y + rect.height;
|
||||||
|
for(var i = 1, l = this.children.length; i < l; i++) {
|
||||||
|
var rect2 = this.children[i].bounds;
|
||||||
|
x1 = Math.min(rect2.x, x1);
|
||||||
|
y1 = Math.min(rect2.y, y1);
|
||||||
|
x2 = Math.max(rect2.x + rect2.width, x1 + x2 - x1);
|
||||||
|
y2 = Math.max(rect2.y + rect2.height, y1 + y2 - y1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new Rectangle(x1, y1, x2 - x1, y2 - y1);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specifies whether the group item is to be clipped.
|
* Specifies whether the group item is to be clipped.
|
||||||
* When setting to true, the first child in the group is automatically
|
* When setting to true, the first child in the group is automatically
|
||||||
|
|
Loading…
Reference in a new issue