mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2025-06-29 22:50:48 -04:00
Merge pull request #522 from yueyuzhao/issue/504-dots-to-sharp-corner
add precise guess first when adding points to paths
This commit is contained in:
commit
ff15b0f5f0
1 changed files with 22 additions and 12 deletions
|
@ -851,7 +851,9 @@ export default class Path {
|
|||
}
|
||||
|
||||
static getHitIndex (ctx, commands, pt) {
|
||||
var drawWithLineMask = function (lineWidth) {
|
||||
ctx.save();
|
||||
ctx.lineWidth = lineWidth;
|
||||
ctx.beginPath();
|
||||
for (var i = 0; i < commands.length; i++) {
|
||||
SVG2Canvas.drawCommand(ctx, commands[i]);
|
||||
|
@ -864,7 +866,15 @@ export default class Path {
|
|||
}
|
||||
ctx.stroke();
|
||||
ctx.restore();
|
||||
return -1;
|
||||
};
|
||||
// When using a mouse to add dragging points to paths,
|
||||
// we need to try a precise guess first.
|
||||
// For more detail see #504
|
||||
var index = drawWithLineMask(2);
|
||||
if (index > -1) {
|
||||
return index;
|
||||
}
|
||||
return drawWithLineMask(Ghost.linemask);
|
||||
}
|
||||
|
||||
static getHitPointIndex (list, pt) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue