mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Move Rectangle#transformCornerCoordinates() to Matrix#_transformCorners().
This commit is contained in:
parent
fc547793fa
commit
f545805786
3 changed files with 11 additions and 16 deletions
|
@ -326,13 +326,22 @@ var Matrix = this.Matrix = Base.extend({
|
|||
return dst;
|
||||
},
|
||||
|
||||
_transformCorners: function(rect) {
|
||||
var x1 = rect.x,
|
||||
y1 = rect.y,
|
||||
x2 = x1 + rect.width,
|
||||
y2 = y1 + rect.height,
|
||||
coords = [ x1, y1, x2, y1, x2, y2, x1, y2 ];
|
||||
return this._transformCoordinates(coords, 0, coords, 0, 4);
|
||||
},
|
||||
|
||||
/**
|
||||
* 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(bounds) {
|
||||
var coords = bounds.transformCornerCoordinates(this),
|
||||
var coords = this._transformCorners(bounds),
|
||||
min = coords.slice(0, 2),
|
||||
max = coords.slice(0);
|
||||
for (var i = 2; i < 8; i++) {
|
||||
|
|
|
@ -229,20 +229,6 @@ var Rectangle = this.Rectangle = Base.extend({
|
|||
+ ' }';
|
||||
},
|
||||
|
||||
transformCornerCoordinates: function(matrix) {
|
||||
var bottom = this.y + this.height,
|
||||
right = this.x + this.width,
|
||||
coords = [
|
||||
this.x, this.y,
|
||||
right, this.y,
|
||||
right, bottom,
|
||||
this.x, bottom
|
||||
];
|
||||
return matrix
|
||||
? matrix._transformCoordinates(coords, 0, coords, 0, 4)
|
||||
: coords;
|
||||
},
|
||||
|
||||
statics: {
|
||||
// See Point.create()
|
||||
create: function(x, y, width, height) {
|
||||
|
|
|
@ -636,7 +636,7 @@ var Item = this.Item = Base.extend({
|
|||
|
||||
statics: {
|
||||
drawSelectedBounds: function(bounds, ctx, matrix) {
|
||||
var coords = bounds.transformCornerCoordinates(matrix);
|
||||
var coords = matrix._transformCorners(bounds);
|
||||
ctx.beginPath();
|
||||
for (var i = 0; i < 8; i++)
|
||||
ctx[i == 0 ? 'moveTo' : 'lineTo'](coords[i], coords[++i]);
|
||||
|
|
Loading…
Reference in a new issue