Move Rectangle#transformCornerCoordinates() to Matrix#_transformCorners().

This commit is contained in:
Jürg Lehni 2011-05-16 12:29:52 +01:00
parent fc547793fa
commit f545805786
3 changed files with 11 additions and 16 deletions

View file

@ -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++) {

View file

@ -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) {

View file

@ -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]);