mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Add Rectangle#transformBounds().
This commit is contained in:
parent
fc776f03eb
commit
aaceeb4f54
1 changed files with 21 additions and 0 deletions
|
@ -243,6 +243,27 @@ var Rectangle = this.Rectangle = Base.extend({
|
|||
: coords;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the 'transformed' bounds rectangle by transforming each corner
|
||||
* point and finding the new bounding box to these points. This is not
|
||||
* really the transformed reactangle!
|
||||
*/
|
||||
transformBounds: function(matrix) {
|
||||
var coords = this.transformCornerCoordinates(matrix),
|
||||
min = coords.slice(0, 2),
|
||||
max = coords.slice(0);
|
||||
for (var i = 2; i < 8; i++) {
|
||||
var val = coords[i],
|
||||
j = i & 1;
|
||||
if (val < min[i])
|
||||
min[i] = val;
|
||||
else if (val > max[i])
|
||||
max[i] = val;
|
||||
}
|
||||
return Rectangle.create(min[0], min[1],
|
||||
max[0] - min[0], max[1] - min[1]);
|
||||
},
|
||||
|
||||
statics: {
|
||||
// See Point.create()
|
||||
create: function(x, y, width, height) {
|
||||
|
|
Loading…
Reference in a new issue