mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-05 20:32:00 -05:00
Add Rectangle#transformCornerCoordinates() and use it in Item.drawSelectedBounds().
This commit is contained in:
parent
9f34042bae
commit
fc776f03eb
2 changed files with 15 additions and 12 deletions
|
@ -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) {
|
||||
|
|
|
@ -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]);
|
||||
|
|
Loading…
Reference in a new issue