mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Have Item#_getBounds return a normal rectangle when called with includeStroke flag, since Item#getStrokeBounds is read only.
This commit is contained in:
parent
eed054af17
commit
1666a36210
1 changed files with 6 additions and 3 deletions
|
@ -445,14 +445,17 @@ var Item = this.Item = Base.extend({
|
||||||
var y2 = x2 = -Infinity;
|
var y2 = x2 = -Infinity;
|
||||||
for (var i = 0, l = children.length; i < l; i++) {
|
for (var i = 0, l = children.length; i < l; i++) {
|
||||||
var child = this.children[i],
|
var child = this.children[i],
|
||||||
rect = includeStroke ? child.getStrokeBounds()
|
rect = includeStroke
|
||||||
|
? child.getStrokeBounds()
|
||||||
: child.getBounds();
|
: child.getBounds();
|
||||||
x1 = Math.min(rect.x, x1);
|
x1 = Math.min(rect.x, x1);
|
||||||
y1 = Math.min(rect.y, y1);
|
y1 = Math.min(rect.y, y1);
|
||||||
x2 = Math.max(rect.x + rect.width, x2);
|
x2 = Math.max(rect.x + rect.width, x2);
|
||||||
y2 = Math.max(rect.y + rect.height, y2);
|
y2 = Math.max(rect.y + rect.height, y2);
|
||||||
}
|
}
|
||||||
return LinkedRectangle.create(this, 'setBounds',
|
return includeStroke
|
||||||
|
? Rectangle.create(x1, y1, x2 - x1, y2 - y1),
|
||||||
|
: LinkedRectangle.create(this, 'setBounds',
|
||||||
x1, y1, x2 - x1, y2 - y1);
|
x1, y1, x2 - x1, y2 - y1);
|
||||||
}
|
}
|
||||||
// TODO: What to return if nothing is defined, e.g. empty Groups?
|
// TODO: What to return if nothing is defined, e.g. empty Groups?
|
||||||
|
|
Loading…
Reference in a new issue