mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Inline Item.drawSelectedBounds() code.
This commit is contained in:
parent
9ee8590a4d
commit
517b2ee27f
2 changed files with 15 additions and 19 deletions
|
@ -2851,22 +2851,6 @@ var Item = this.Item = Base.extend(Callback, {
|
||||||
// Return the temporary context, so it can be reused
|
// Return the temporary context, so it can be reused
|
||||||
CanvasProvider.release(ctx);
|
CanvasProvider.release(ctx);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
statics: {
|
|
||||||
drawSelectedBounds: function(bounds, ctx, matrix) {
|
|
||||||
var coords = matrix._transformCorners(bounds);
|
|
||||||
ctx.beginPath();
|
|
||||||
for (var i = 0; i < 8; i++)
|
|
||||||
ctx[i == 0 ? 'moveTo' : 'lineTo'](coords[i], coords[++i]);
|
|
||||||
ctx.closePath();
|
|
||||||
ctx.stroke();
|
|
||||||
for (var i = 0; i < 8; i++) {
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.rect(coords[i] - 2, coords[++i] - 2, 4, 4);
|
|
||||||
ctx.fill();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, Base.each(['down', 'drag', 'up', 'move'], function(name) {
|
}, Base.each(['down', 'drag', 'up', 'move'], function(name) {
|
||||||
this['removeOn' + Base.capitalize(name)] = function() {
|
this['removeOn' + Base.capitalize(name)] = function() {
|
||||||
|
|
|
@ -317,11 +317,23 @@ var Project = this.Project = PaperScopeItem.extend(/** @lends Project# */{
|
||||||
var mx = item._globalMatrix;
|
var mx = item._globalMatrix;
|
||||||
if (item.drawSelected)
|
if (item.drawSelected)
|
||||||
item.drawSelected(ctx, mx);
|
item.drawSelected(ctx, mx);
|
||||||
if (item._boundsSelected)
|
if (item._boundsSelected) {
|
||||||
// We need to call the internal _getBounds, to get non-
|
// We need to call the internal _getBounds, to get non-
|
||||||
// transformed bounds.
|
// transformed bounds.
|
||||||
Item.drawSelectedBounds(item._getBounds('getBounds'),
|
var coords = mx._transformCorners(
|
||||||
ctx, mx);
|
item._getBounds('getBounds'));
|
||||||
|
ctx.beginPath();
|
||||||
|
for (var i = 0; i < 8; i++)
|
||||||
|
ctx[i === 0 ? 'moveTo' : 'lineTo'](
|
||||||
|
coords[i], coords[++i]);
|
||||||
|
ctx.closePath();
|
||||||
|
ctx.stroke();
|
||||||
|
for (var i = 0; i < 8; i++) {
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.rect(coords[i] - 2, coords[++i] - 2, 4, 4);
|
||||||
|
ctx.fill();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.restore();
|
ctx.restore();
|
||||||
|
|
Loading…
Reference in a new issue