From 76eb0b9e3ef24e76dda1deeda7e8599c9bfe897b Mon Sep 17 00:00:00 2001 From: DD Date: Wed, 14 Mar 2018 18:12:37 -0400 Subject: [PATCH 1/3] Reduce the overlap to .25 --- src/helper/math.js | 14 +++++++------- src/helper/tools/fill-tool.js | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/helper/math.js b/src/helper/math.js index 11eab4a4..2da863a5 100644 --- a/src/helper/math.js +++ b/src/helper/math.js @@ -82,17 +82,17 @@ const sortItemsByZIndex = function (a, b) { return null; }; -// Expand the size of the path by approx one pixel all around -const expandByOne = function (path) { +// Expand the size of the path by amount all around +const expandBy = function (path, amount) { const center = path.position; let pathArea = path.area; for (const seg of path.segments) { - const halfNorm = seg.point.subtract(center) + const delta = seg.point.subtract(center) .normalize() - .divide(2); - seg.point = seg.point.add(halfNorm); + .multiply(amount); + seg.point = seg.point.add(delta); // If that made the path area smaller, go the other way. - if (path.area < pathArea) seg.point = seg.point.subtract(halfNorm.multiply(2)); + if (path.area < pathArea) seg.point = seg.point.subtract(delta.multiply(2)); pathArea = path.area; } }; @@ -112,7 +112,7 @@ export { HANDLE_RATIO, checkPointsClose, ensureClockwise, - expandByOne, + expandBy, getRandomInt, getRandomBoolean, snapDeltaToAngle, diff --git a/src/helper/tools/fill-tool.js b/src/helper/tools/fill-tool.js index 55a88308..30208b74 100644 --- a/src/helper/tools/fill-tool.js +++ b/src/helper/tools/fill-tool.js @@ -1,6 +1,6 @@ import paper from '@scratch/paper'; import {getHoveredItem} from '../hover'; -import {expandByOne} from '../math'; +import {expandBy} from '../math'; class FillTool extends paper.Tool { static get TOLERANCE () { @@ -104,7 +104,7 @@ class FillTool extends paper.Tool { this.addedFillItem.data.origItem = hitItem; // This usually fixes it so there isn't a teeny tiny gap in between the fill and the outline // when filling in a hole - expandByOne(this.addedFillItem); + expandBy(this.addedFillItem, .5); this.addedFillItem.insertAbove(hitItem.parent); } else if (this.fillItem.parent instanceof paper.CompoundPath) { this.fillItemOrigColor = hitItem.parent.fillColor; From 69e73d45ddf0283cba5028316169679583e7859d Mon Sep 17 00:00:00 2001 From: DD Date: Fri, 16 Mar 2018 14:18:42 -0400 Subject: [PATCH 2/3] Use .25 --- src/helper/tools/fill-tool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/tools/fill-tool.js b/src/helper/tools/fill-tool.js index 30208b74..2ed588b5 100644 --- a/src/helper/tools/fill-tool.js +++ b/src/helper/tools/fill-tool.js @@ -104,7 +104,7 @@ class FillTool extends paper.Tool { this.addedFillItem.data.origItem = hitItem; // This usually fixes it so there isn't a teeny tiny gap in between the fill and the outline // when filling in a hole - expandBy(this.addedFillItem, .5); + expandBy(this.addedFillItem, .25); this.addedFillItem.insertAbove(hitItem.parent); } else if (this.fillItem.parent instanceof paper.CompoundPath) { this.fillItemOrigColor = hitItem.parent.fillColor; From a03567ef18919db0bb6189ef5d46ecd10e6dc960 Mon Sep 17 00:00:00 2001 From: DD Date: Fri, 16 Mar 2018 14:23:59 -0400 Subject: [PATCH 3/3] Switch to .1 --- src/helper/tools/fill-tool.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/tools/fill-tool.js b/src/helper/tools/fill-tool.js index 2ed588b5..8360c161 100644 --- a/src/helper/tools/fill-tool.js +++ b/src/helper/tools/fill-tool.js @@ -104,7 +104,7 @@ class FillTool extends paper.Tool { this.addedFillItem.data.origItem = hitItem; // This usually fixes it so there isn't a teeny tiny gap in between the fill and the outline // when filling in a hole - expandBy(this.addedFillItem, .25); + expandBy(this.addedFillItem, .1); this.addedFillItem.insertAbove(hitItem.parent); } else if (this.fillItem.parent instanceof paper.CompoundPath) { this.fillItemOrigColor = hitItem.parent.fillColor;