From 2d790a3f34922647abb5c04b1ed929daf93fe539 Mon Sep 17 00:00:00 2001 From: DD Date: Mon, 4 Dec 2017 18:23:42 -0500 Subject: [PATCH] Copy changes in selection mode to src files --- AUTHORS.md | 1 + src/item/Item.js | 1 + src/path/Path.js | 36 ++++++++++++++++++++---------------- 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/AUTHORS.md b/AUTHORS.md index 547c42e0..20182809 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -13,3 +13,4 @@ - Justin Ridgewell - Andrew Wagenheim - Scott Kieronski +- DD Liu diff --git a/src/item/Item.js b/src/item/Item.js index 6b8183f2..9d94181b 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -4408,6 +4408,7 @@ new function() { // Injection scope for hit-test functions shared with project half = size / 2; ctx.strokeStyle = ctx.fillStyle = color ? color.toCanvasStyle(ctx) : '#009dec'; + ctx.lineWidth=2.5; if (itemSelected) this._drawSelected(ctx, mx, selectionItems); if (positionSelected) { diff --git a/src/path/Path.js b/src/path/Path.js index 42eaa34e..52d555c1 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -2135,7 +2135,7 @@ new function() { // Scope for drawing // SegmentPoint objects maybe seem a bit tedious but is worth the benefit in // performance. - function drawHandles(ctx, segments, matrix, size) { + function drawHandles(ctx, segments, matrix, size, isFullySelected) { var half = size / 2, coords = new Array(6), pX, pY; @@ -2147,10 +2147,12 @@ new function() { // Scope for drawing ctx.beginPath(); ctx.moveTo(pX, pY); ctx.lineTo(hX, hY); + ctx.moveTo(hX - half, hY); + ctx.lineTo(hX, hY + half); + ctx.lineTo(hX + half, hY); + ctx.lineTo(hX, hY - half); + ctx.closePath(); ctx.stroke(); - ctx.beginPath(); - ctx.arc(hX, hY, half, 0, Math.PI * 2, true); - ctx.fill(); } } @@ -2160,20 +2162,22 @@ new function() { // Scope for drawing segment._transformCoordinates(matrix, coords); pX = coords[0]; pY = coords[1]; - if (selection & /*#=*/SegmentSelection.HANDLE_IN) - drawHandle(2); - if (selection & /*#=*/SegmentSelection.HANDLE_OUT) - drawHandle(4); - // Draw a rectangle at segment.point: - 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: + // Don't draw handles when the shape is fully selected. + if (selection & /*#=*/SegmentSelection.HANDLE_IN && !isFullySelected) + drawHandle(/*#=*/SegmentSelection.HANDLE_IN); + if (selection & /*#=*/SegmentSelection.HANDLE_OUT && !isFullySelected) + drawHandle(/*#=*/SegmentSelection.HANDLE_OUT); + // Draw a circle at segment.point: + ctx.beginPath(); + ctx.arc(pX, pY, half, 0, Math.PI * 2, true); + ctx.stroke(); + var fillStyle = ctx.fillStyle; + // If the point is not selected, fill the point with semitransparent white: if (!(selection & /*#=*/SegmentSelection.POINT)) { - var fillStyle = ctx.fillStyle; - ctx.fillStyle = '#ffffff'; - ctx.fillRect(pX - half + 1, pY - half + 1, size - 2, size - 2); - ctx.fillStyle = fillStyle; + ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; } + ctx.fill(); + ctx.fillStyle = fillStyle; } }