From 41e0765657ff495b8b3f840eac087a4599f3cab0 Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Fri, 8 Nov 2019 14:04:57 -0500 Subject: [PATCH 1/2] Skip processing of child paths in mergeEraser --- src/helper/blob-tools/blob.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helper/blob-tools/blob.js b/src/helper/blob-tools/blob.js index 60615f8532..3c9fc19051 100644 --- a/src/helper/blob-tools/blob.js +++ b/src/helper/blob-tools/blob.js @@ -5,6 +5,7 @@ import SegmentBrushHelper from './segment-brush-helper'; import {MIXED, styleCursorPreview} from '../../helper/style-path'; import {clearSelection, getItems} from '../../helper/selection'; import {getGuideLayer} from '../../helper/layer'; +import {isCompoundPathChild} from '../compound-path'; /** * Shared code for the brush and eraser mode. Adds functions on the paper tool object @@ -263,8 +264,12 @@ class Blobbiness { class: paper.PathItem }); } - + for (let i = items.length - 1; i >= 0; i--) { + // If a path is part of a compound path, that parent path will later be processed. + // Skip processing the child path so as not to double-process it. + if (isCompoundPathChild(items[i])) continue; + // TODO handle compound paths if (items[i] instanceof paper.Path && (!items[i].fillColor || items[i].fillColor._alpha === 0)) { // Gather path segments From 1c6425f9e395c73544fdf444c6ba04f2123521bd Mon Sep 17 00:00:00 2001 From: adroitwhiz Date: Tue, 21 Apr 2020 21:29:30 -0400 Subject: [PATCH 2/2] Filter out compound path children *before* looping --- src/helper/blob-tools/blob.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/helper/blob-tools/blob.js b/src/helper/blob-tools/blob.js index 3c9fc19051..ec3923a38a 100644 --- a/src/helper/blob-tools/blob.js +++ b/src/helper/blob-tools/blob.js @@ -42,7 +42,7 @@ class Blobbiness { this.brushSize = null; this.fillColor = null; } - + /** * Set configuration options for a blob * @param {!object} options Configuration @@ -93,7 +93,7 @@ class Blobbiness { blob.cursorPreview.bringToFront(); blob.cursorPreview.position = event.point; }; - + this.tool.onMouseDown = function (event) { blob.resizeCursorIfNeeded(event.point); if (event.event.button > 0) return; // only first mouse button @@ -126,7 +126,7 @@ class Blobbiness { this.tool.onMouseUp = function (event) { if (event.event.button > 0 || !this.active) return; // only first mouse button - + let lastPath; if (blob.brush === Blobbiness.BROAD) { lastPath = blob.broadBrushHelper.onBroadMouseUp(event, blob.tool, blob.options); @@ -249,7 +249,11 @@ class Blobbiness { // If there are selected items, try to erase from amongst those. let items = getItems({ match: function (item) { - return item.selected && blob.isMergeable(lastPath, item) && blob.touches(lastPath, item); + return item.selected && blob.isMergeable(lastPath, item) && + blob.touches(lastPath, item) && + // Boolean operations will produce incorrect results if directly applied to compound path children, + // so exclude those. Their parents are also selected so boolean operations will apply to them. + !isCompoundPathChild(item); }, class: paper.PathItem }); @@ -259,17 +263,15 @@ class Blobbiness { clearSelection(this.clearSelectedItems); items = getItems({ match: function (item) { - return blob.isMergeable(lastPath, item) && blob.touches(lastPath, item); + return blob.isMergeable(lastPath, item) && + blob.touches(lastPath, item) && + !isCompoundPathChild(item); }, class: paper.PathItem }); } for (let i = items.length - 1; i >= 0; i--) { - // If a path is part of a compound path, that parent path will later be processed. - // Skip processing the child path so as not to double-process it. - if (isCompoundPathChild(items[i])) continue; - // TODO handle compound paths if (items[i] instanceof paper.Path && (!items[i].fillColor || items[i].fillColor._alpha === 0)) { // Gather path segments