Add Rectangle#transformCornerCoordinates() and use it in Item.drawSelectedBounds().

This commit is contained in:
Jürg Lehni 2011-05-16 11:25:39 +01:00
parent 9f34042bae
commit fc776f03eb
2 changed files with 15 additions and 12 deletions

View file

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

View file

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