mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Optimize and fix code that draws selections and handles.
This commit is contained in:
parent
dad17ba28e
commit
763fd5b6a3
2 changed files with 10 additions and 14 deletions
|
@ -1929,19 +1929,15 @@ var Path = PathItem.extend(/** @lends Path# */{
|
|||
if (state & /*#=*/ SelectionState.HANDLE_OUT)
|
||||
drawHandle(4);
|
||||
// Draw a rectangle at segment.point:
|
||||
ctx.save();
|
||||
ctx.beginPath();
|
||||
ctx.rect(pX - half, pY - half, size, size);
|
||||
ctx.fill();
|
||||
ctx.fillRect(pX - half, pY - half, size, size);
|
||||
// If the point is not selected, draw a white square that is 1 px
|
||||
// smaller on all sides:
|
||||
if (!(state & /*#=*/ SelectionState.POINT)) {
|
||||
ctx.beginPath();
|
||||
ctx.rect(pX - half + 1, pY - half + 1, size - 2, size - 2);
|
||||
var fillStyle = ctx.fillStyle;
|
||||
ctx.fillStyle = '#ffffff';
|
||||
ctx.fill();
|
||||
ctx.fillRect(pX - half + 1, pY - half + 1, size - 2, size - 2);
|
||||
ctx.fillStyle = fillStyle;
|
||||
}
|
||||
ctx.restore();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -450,7 +450,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
ctx.save();
|
||||
ctx.strokeWidth = 1;
|
||||
for (var id in this._selectedItems) {
|
||||
var item = this._selectedItems[id];
|
||||
var item = this._selectedItems[id],
|
||||
size = this.options.handleSize || 4;
|
||||
half = size / 2;
|
||||
if (item._updateVersion === this._updateVersion
|
||||
&& (item._drawSelected || item._boundsSelected)) {
|
||||
// Allow definition of selected color on a per item and per
|
||||
|
@ -473,11 +475,9 @@ var Project = PaperScopeItem.extend(/** @lends Project# */{
|
|||
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();
|
||||
}
|
||||
for (var i = 0; i < 8; i++)
|
||||
ctx.fillRect(coords[i] - half, coords[++i] - half,
|
||||
size, size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue