From bc8fb92b9d3339b173a3a0f1599e90537146cbaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 7 Jan 2016 15:55:24 +0100 Subject: [PATCH] Rename some variables to be more clear about their role. --- src/path/PathItem.Boolean.js | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index ae32f3bd..88886a53 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -358,22 +358,24 @@ PathItem.inject(new function() { end = start + curve.length; // Walk through one single loop of curves. var startCounted = false, - prevCurve, // non-horizontal curve before the current curve. - nextCurve, // non-horizontal curve after the current curve. + prevWinding, // The previous non-horizontal curve. + nextWinding, // The next non-horizontal curve (with winding) prevT = null, curve = null; for (var i = start; i < end; i++) { if (!curve) { - prevCurve = lastWinding; - nextCurve = firstWinding; + prevWinding = lastWinding; + nextWinding = firstWinding; } else if (curve.winding) { - prevCurve = curve; + prevWinding = curve; } curve = curves[i]; - if (curve === nextCurve) { - nextCurve = curve.next; - while (nextCurve && !nextCurve.winding) { - nextCurve = nextCurve.next; + if (curve === nextWinding) { + // Each time we've reached the next curve with winding, + // search for the next one after. + nextWinding = curve.next; + while (nextWinding && !nextWinding.winding) { + nextWinding = nextWinding.next; } } var values = curve.values, @@ -405,10 +407,10 @@ PathItem.inject(new function() { // Take care of cases where the ray merely touches // the connecting point between two neighboring mono // curves, but does not cross either of them. - if (t < tMin && prevCurve - && winding * prevCurve.winding < 0 - || t > tMax && nextCurve - && winding * nextCurve.winding < 0) { + if (t < tMin && prevWinding + && winding * prevWinding.winding < 0 + || t > tMax && nextWinding + && winding * nextWinding.winding < 0) { if (x > xBefore && x < xAfter) { ++windLeft; ++windRight; @@ -431,11 +433,11 @@ PathItem.inject(new function() { // If the point is on a horizontal curve and winding // changes between before and after the curve, we treat // this as a 'touch point'. - if (py === values[1] - && (values[0] < xAfter && values[6] > xBefore + if (prevWinding && nextWinding + && py === values[1] + && (values[0] < xAfter && values[6] > xBefore || values[6] < xAfter && values[0] > xBefore) - && prevCurve && nextCurve - && prevCurve.winding * nextCurve.winding < 0) { + && prevWinding.winding * nextWinding.winding < 0) { ++windLeft; ++windRight; }