mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-08 05:42:07 -05:00
Add dest and dontNotifty arguments to Matrix#_transformBounds() and use them where appropriate.
This commit is contained in:
parent
3f5e68aa76
commit
1d6cfeeb9b
3 changed files with 13 additions and 6 deletions
|
@ -414,7 +414,7 @@ var Matrix = this.Matrix = Base.extend(/** @lends Matrix# */{
|
||||||
* point and finding the new bounding box to these points. This is not
|
* point and finding the new bounding box to these points. This is not
|
||||||
* really the transformed reactangle!
|
* really the transformed reactangle!
|
||||||
*/
|
*/
|
||||||
_transformBounds: function(bounds) {
|
_transformBounds: function(bounds, dest, dontNotify) {
|
||||||
var coords = this._transformCorners(bounds),
|
var coords = this._transformCorners(bounds),
|
||||||
min = coords.slice(0, 2),
|
min = coords.slice(0, 2),
|
||||||
max = coords.slice(0);
|
max = coords.slice(0);
|
||||||
|
@ -426,8 +426,10 @@ var Matrix = this.Matrix = Base.extend(/** @lends Matrix# */{
|
||||||
else if (val > max[j])
|
else if (val > max[j])
|
||||||
max[j] = val;
|
max[j] = val;
|
||||||
}
|
}
|
||||||
return Rectangle.create(min[0], min[1],
|
if (!dest)
|
||||||
max[0] - min[0], max[1] - min[1]);
|
dest = new Rectangle(Rectangle.dont);
|
||||||
|
return dest.set(min[0], min[1], max[0] - min[0], max[1] - min[1],
|
||||||
|
dontNotify);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1699,8 +1699,13 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
|
||||||
// and transform the cached _bounds and _position without having to
|
// and transform the cached _bounds and _position without having to
|
||||||
// fully recalculate each time.
|
// fully recalculate each time.
|
||||||
if (bounds && matrix.getRotation() % 90 === 0) {
|
if (bounds && matrix.getRotation() % 90 === 0) {
|
||||||
this._bounds = this._createBounds(
|
// Transform the old _bounds without notifying it of changes
|
||||||
matrix._transformBounds(bounds));
|
this._bounds = matrix._transformBounds(bounds, bounds, true);
|
||||||
|
// Update _position again, by linking it to _bounds
|
||||||
|
// TODO: If LinkedPoint would not just sync writes, but reads too,
|
||||||
|
// we could do this: this._position = position;
|
||||||
|
// This is a bug currently in Paper.js, that should be fixed, but
|
||||||
|
// can only really be handled properly using versioning...
|
||||||
this._position = this._bounds.getCenter();
|
this._position = this._bounds.getCenter();
|
||||||
} else if (position) {
|
} else if (position) {
|
||||||
// Transform position as well. Do not notify _position of
|
// Transform position as well. Do not notify _position of
|
||||||
|
|
|
@ -129,7 +129,7 @@ var PointText = this.PointText = TextItem.extend(/** @lends PointText# */{
|
||||||
// rough guess
|
// rough guess
|
||||||
var bounds = Rectangle.create(x, leading / 4 + (count - 1) * leading,
|
var bounds = Rectangle.create(x, leading / 4 + (count - 1) * leading,
|
||||||
width, -count * leading);
|
width, -count * leading);
|
||||||
bounds = this._matrix._transformBounds(bounds);
|
this._matrix._transformBounds(bounds, bounds);
|
||||||
// TODO: Only cache if no matrix is provided
|
// TODO: Only cache if no matrix is provided
|
||||||
this[cacheName] = bounds;
|
this[cacheName] = bounds;
|
||||||
return getter == 'getBounds' ? this._createBounds(bounds) : bounds;
|
return getter == 'getBounds' ? this._createBounds(bounds) : bounds;
|
||||||
|
|
Loading…
Reference in a new issue