From 9404c5a0e32ec198bb7af75294d9b2bbc64140fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sat, 2 Jan 2016 23:39:13 +0100 Subject: [PATCH] Restructure code from #883 a bit - Use === instead of == for strict numeric comparisons - Merge the two return statements to one - Address some imprecisions in previously added comments --- src/path/Curve.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index 901a5fb4..0721c8e3 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1462,13 +1462,13 @@ new function() { // Scope for intersection using bezier fat-line clipping bottom = hull[1], tMinClip, tMaxClip; - // Stop iteration if all points and control points are exactly collinear. - if (d1 == 0 && d2 == 0 && dp0 == 0 && dp1 == 0 && dp2 == 0 && dp3 == 0) - return; - // Clip the convex-hull with dMin and dMax, taking into account that - // there will be no intersections if one of the tvalues are null. - if ((tMinClip = clipConvexHull(top, bottom, dMin, dMax)) == null || - (tMaxClip = clipConvexHull(top.reverse(), bottom.reverse(), + // Stop iteration if all points and control points are collinear. + if (d1 === 0 && d2 === 0 + && dp0 === 0 && dp1 === 0 && dp2 === 0 && dp3 === 0 + // Clip the convex-hull with dMin and dMax, taking into account that + // there will be no intersections if one of the tvalues are null. + || (tMinClip = clipConvexHull(top, bottom, dMin, dMax)) == null + || (tMaxClip = clipConvexHull(top.reverse(), bottom.reverse(), dMin, dMax)) == null) return; // tMin and tMax are within the range (0, 1). We need to project it @@ -1490,7 +1490,7 @@ new function() { // Scope for intersection using bezier fat-line clipping reverse ? v2 : v1, reverse ? c2 : c1, reverse ? u : t, null, reverse ? v1 : v2, reverse ? c1 : c2, reverse ? t : u, null); } else { - // Clip P with the fat-line for Q + // Apply the result of the clipping to curve 1: var v1Clip = Curve.getPart(v1, tMinClip, tMaxClip), tDiff = tMaxClip - tMinClip; if (oldTDiff > 0.5 && tDiff > 0.5) { @@ -1518,9 +1518,9 @@ new function() { // Scope for intersection using bezier fat-line clipping addCurveIntersections(v2, v1Clip, c2, c1, locations, param, uMin, uMax, tMinNew, tMaxNew, tDiff, !reverse, recursion); } else { - // P has converged to a point. Since we cannot construct a fat- - // line from a point, we dismiss this clipping so we can - // continue with clipping Q. + // Curve 1 has converged to a point. Since we cannot construct a + // fat-line from a point, we dismiss this clipping so we can + // continue clipping curve 2. addCurveIntersections(v2, v1, c2, c1, locations, param, uMin, uMax, tMin, tMax, tDiff, !reverse, recursion); }