From 4d6ebe2f3f57c9996b3514982e2c6fcc08e2bd2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 4 Feb 2017 21:38:17 +0100 Subject: [PATCH] Switch to absolute winding values in getWinding() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That’s what the previous code was already doing, but cryptically so. Relates to #1073 --- src/path/PathItem.Boolean.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index a1d24a66..b7fca43b 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -42,7 +42,7 @@ PathItem.inject(new function() { intersect: { '2': true }, subtract: { '1': true }, // exclude only needs -1 to support reorientPaths() when there are - // no crossings. + // no crossings. The actual boolean code uses unsigned winding. exclude: { '1': true, '-1': true } }; @@ -673,13 +673,12 @@ PathItem.inject(new function() { vClose = null; } } - // TODO: If the winding one - windingL = windingL && (2 - abs(windingL) % 2); - windingR = windingR && (2 - abs(windingR) % 2); - // Return the calculated winding contribution and detect if we are - // on the contour of the area by comparing windingL and windingR. - // This is required when handling unite operations, where a winding - // number of 2 is not part of the result unless it's the contour: + // Use the unsigned winding contributions when determining which areas + // are part of the boolean result. + windingL = abs(windingL); + windingR = abs(windingR); + // Return the calculated winding contributions along with a quality + // value indicating how reliable the value really is. return { winding: max(windingL, windingR), windingL: windingL,