diff --git a/src/basic/Rectangle.js b/src/basic/Rectangle.js index 133ecded..25298991 100644 --- a/src/basic/Rectangle.js +++ b/src/basic/Rectangle.js @@ -229,6 +229,20 @@ 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) { diff --git a/src/item/Item.js b/src/item/Item.js index fb931e49..866e796d 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -636,18 +636,7 @@ var Item = this.Item = Base.extend({ statics: { drawSelectedBounds: function(bounds, ctx, matrix) { - var top = bounds.y, - bottom = bounds.y + bounds.height, - left = bounds.x, - right = bounds.x + bounds.width; - coords = [ - left, top, - right, top, - right, bottom, - left, bottom - ]; - if (matrix) - matrix._transformCoordinates(coords, 0, coords, 0, 4); + var coords = bounds.transformCornerCoordinates(matrix); ctx.beginPath(); for (var i = 0; i < 8; i++) ctx[i == 0 ? 'moveTo' : 'lineTo'](coords[i], coords[++i]);