mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2024-12-22 21:42:30 -05:00
Add handle padding and radius
This commit is contained in:
parent
ec3348dc75
commit
e22295b68c
1 changed files with 15 additions and 2 deletions
|
@ -33,6 +33,18 @@ const ReshapeModes = keyMirror({
|
||||||
class ReshapeTool extends paper.Tool {
|
class ReshapeTool extends paper.Tool {
|
||||||
/** Distance within which mouse is considered to be hitting an item */
|
/** Distance within which mouse is considered to be hitting an item */
|
||||||
static get TOLERANCE () {
|
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;
|
return 5.25;
|
||||||
}
|
}
|
||||||
/** Clicks registered within this amount of time are registered as double clicks */
|
/** 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.onKeyUp = this.handleKeyUp;
|
||||||
this.onKeyDown = this.handleKeyDown;
|
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
|
// 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
|
* Returns the hit options for segments to use when conducting hit tests. Segments are only visible
|
||||||
|
|
Loading…
Reference in a new issue