From b9a07ca538b83dfb07d4fff0f481b94aa2369ba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Mon, 31 Aug 2015 22:01:18 +0200 Subject: [PATCH] Address code comments by @iconexperience in #762. --- src/path/Curve.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index ebf1ffe8..efe205e6 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -1271,7 +1271,8 @@ new function() { // Scope for methods that require private functions dp1 = getSignedDistance(q0x, q0y, q3x, q3y, v1[2], v1[3]), dp2 = getSignedDistance(q0x, q0y, q3x, q3y, v1[4], v1[5]), dp3 = getSignedDistance(q0x, q0y, q3x, q3y, v1[6], v1[7]), - tMinNew, tMaxNew, tDiff; + tMinNew, tMaxNew, + tDiff; if (q0x === q3x && uMax - uMin < tolerance && recursion >= 3) { // The fat-line of Q has converged to a point, the clipping is not // reliable. Return the value we have even though we will miss the @@ -1284,13 +1285,11 @@ new function() { // Scope for methods that require private functions top = hull[0], bottom = hull[1], tMinClip, tMaxClip; - // Clip the convex-hull with dMin and dMax - tMinClip = clipConvexHull(top, bottom, dMin, dMax); - top.reverse(); - bottom.reverse(); - tMaxClip = clipConvexHull(top, bottom, dMin, dMax); - // No intersections if one of the tvalues are null or 'undefined' - if (tMinClip == null || tMaxClip == null) + // 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(), + dMin, dMax)) == null) return; // Clip P with the fat-line for Q v1 = Curve.getPart(v1, tMinClip, tMaxClip);