From e110a04093aacfb878b08efd5af6bc6579fc7386 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Sat, 11 Apr 2020 10:56:45 -0400 Subject: [PATCH 1/3] Set reshape handle size to match hit tolerance --- src/helper/selection-tools/reshape-tool.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/helper/selection-tools/reshape-tool.js b/src/helper/selection-tools/reshape-tool.js index 003e3393..6f19a66d 100644 --- a/src/helper/selection-tools/reshape-tool.js +++ b/src/helper/selection-tools/reshape-tool.js @@ -74,7 +74,9 @@ class ReshapeTool extends paper.Tool { this.onKeyUp = this.handleKeyUp; this.onKeyDown = this.handleKeyDown; - paper.settings.handleSize = 8; + // A handle's size is given in diameter, and each handle has a 2.5-pixel stroke that isn't part of its size. + // Size the handles such that clicking on either the stroke or the handle itself will be registered as a drag + paper.settings.handleSize = (ReshapeTool.TOLERANCE * 2) - 2.5; } /** * Returns the hit options for segments to use when conducting hit tests. Segments are only visible From ec3348dc75fdf827cd611d5f67c3bf17e23259ef Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Sat, 11 Apr 2020 10:58:04 -0400 Subject: [PATCH 2/3] Increase reshape tool tolerance to match handle size This causes the new dynamically-sized reshape handles to match their previous size. --- src/helper/selection-tools/reshape-tool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/selection-tools/reshape-tool.js b/src/helper/selection-tools/reshape-tool.js index 6f19a66d..99d075c7 100644 --- a/src/helper/selection-tools/reshape-tool.js +++ b/src/helper/selection-tools/reshape-tool.js @@ -33,7 +33,7 @@ const ReshapeModes = keyMirror({ class ReshapeTool extends paper.Tool { /** Distance within which mouse is considered to be hitting an item */ static get TOLERANCE () { - return 4; + return 5.25; } /** Clicks registered within this amount of time are registered as double clicks */ static get DOUBLE_CLICK_MILLIS () { From e22295b68c2e03082cdf609a7da7dded323b134d Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Tue, 26 May 2020 16:10:25 -0400 Subject: [PATCH 3/3] Add handle padding and radius --- src/helper/selection-tools/reshape-tool.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/helper/selection-tools/reshape-tool.js b/src/helper/selection-tools/reshape-tool.js index 99d075c7..527405a3 100644 --- a/src/helper/selection-tools/reshape-tool.js +++ b/src/helper/selection-tools/reshape-tool.js @@ -33,6 +33,18 @@ const ReshapeModes = keyMirror({ class ReshapeTool extends paper.Tool { /** Distance within which mouse is considered to be hitting an item */ static get TOLERANCE () { + return ReshapeTool.HANDLE_RADIUS + ReshapeTool.HANDLE_PADDING; + } + /** + * Units of padding around the visible handle area that will still register clicks as "touching the handle" + */ + static get HANDLE_PADDING () { + return 1; + } + /** + * Handles' radius, including the stroke + */ + static get HANDLE_RADIUS () { return 5.25; } /** Clicks registered within this amount of time are registered as double clicks */ @@ -74,9 +86,10 @@ class ReshapeTool extends paper.Tool { this.onKeyUp = this.handleKeyUp; this.onKeyDown = this.handleKeyDown; - // A handle's size is given in diameter, and each handle has a 2.5-pixel stroke that isn't part of its size. + // A handle's size is given in diameter, and each handle has a 2.5-pixel stroke that isn't part of its size: + // https://github.com/LLK/paper.js/blob/a187e4c81cc63f3d48c5097b9a9fbddde9f057da/src/item/Item.js#L4480 // Size the handles such that clicking on either the stroke or the handle itself will be registered as a drag - paper.settings.handleSize = (ReshapeTool.TOLERANCE * 2) - 2.5; + paper.settings.handleSize = (ReshapeTool.HANDLE_RADIUS * 2) - 2.5; } /** * Returns the hit options for segments to use when conducting hit tests. Segments are only visible