From 4f9d23da81580e2d8a4d9c470b18a9a9abb16c65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 16 Feb 2017 13:41:53 +0100 Subject: [PATCH] Use consistent boundary policy when dealing with curve-time. --- src/path/Curve.js | 4 ++-- src/path/CurveLocation.js | 14 +++++++------- src/path/Path.js | 2 +- src/path/PathItem.Boolean.js | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index deeb59b3..989a7efb 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -890,7 +890,7 @@ statics: /** @lends Curve */{ var t = roots[i], u = 1 - t; // Test for good roots and only add to bounds if good. - if (tMin < t && t < tMax) + if (tMin <= t && t <= tMax) // Calculate bezier polynomial at t. add(u * u * u * v0 + 3 * u * u * t * v1 @@ -1725,7 +1725,7 @@ new function() { // Scope for bezier intersection using fat-line clipping t1 = Curve.getTimeOf(v1, p1); // Check t1 and t2 against correct bounds, based on excludeStart/End: // - excludeStart means the start of c1 connects to the end of c2 - // - endConneted means the end of c1 connects to the start of c2 + // - excludeEnd means the end of c1 connects to the start of c2 // - If either c1 or c2 are at the end of the path, exclude their end, // which connects back to the beginning, but only if it's not part of // a found overlap. The normal intersection will already be found at diff --git a/src/path/CurveLocation.js b/src/path/CurveLocation.js index 75b6ecde..db6b35f4 100644 --- a/src/path/CurveLocation.js +++ b/src/path/CurveLocation.js @@ -41,7 +41,7 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ initialize: function CurveLocation(curve, time, point, _overlap, _distance) { // Merge intersections very close to the end of a curve with the // beginning of the next curve. - if (time > /*#=*/(1 - Numerical.CURVETIME_EPSILON)) { + if (time >= /*#=*/(1 - Numerical.CURVETIME_EPSILON)) { var next = curve.getNext(); if (next) { time = 0; @@ -402,8 +402,8 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ tMin = /*#=*/Numerical.CURVETIME_EPSILON, tMax = 1 - tMin, // t*Inside specifies if the found intersection is inside the curve. - t1Inside = t1 > tMin && t1 < tMax, - t2Inside = t2 > tMin && t2 < tMax; + t1Inside = t1 >= tMin && t1 <= tMax, + t2Inside = t2 >= tMin && t2 <= tMax; // If the intersection is in the middle of both paths, it is either a // tangent or a crossing, no need for the detailed corner check below: if (t1Inside && t2Inside) @@ -416,13 +416,13 @@ var CurveLocation = Base.extend(/** @lends CurveLocation# */{ // both values point to the same curve, and the curve-time is to be // handled accordingly further down. var c2 = this.getCurve(), - c1 = t1 <= tMin ? c2.getPrevious() : c2, + c1 = t1 < tMin ? c2.getPrevious() : c2, c4 = inter.getCurve(), - c3 = t2 <= tMin ? c4.getPrevious() : c4; + c3 = t2 < tMin ? c4.getPrevious() : c4; // If t1 / t2 are at the end, then step to the next curve. - if (t1 >= tMax) + if (t1 > tMax) c2 = c2.getNext(); - if (t2 >= tMax) + if (t2 > tMax) c4 = c4.getNext(); if (!c1 || !c2 || !c3 || !c4) return false; diff --git a/src/path/Path.js b/src/path/Path.js index 9f7a61e9..d282608b 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -1043,7 +1043,7 @@ var Path = PathItem.extend(/** @lends Path# */{ time = loc && loc.time, tMin = /*#=*/Numerical.CURVETIME_EPSILON, tMax = 1 - tMin; - if (time >= tMax) { + if (time > tMax) { // time == 1 is the same location as time == 0 and index++ index++; time = 0; diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 605029ad..4fafa2ba 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -371,7 +371,7 @@ PathItem.inject(new function() { // renormalization within the curve. renormalizeLocs = []; prevTime = null; - } else if (prevTime > tMin) { + } else if (prevTime >= tMin) { // Rescale curve-time when we are splitting the same curve // multiple times, if splitting was done previously. loc._time /= prevTime;