diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 3f0630ce..84fac114 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -164,17 +164,14 @@ PathItem.inject(new function() { */ function splitPath(intersections) { var TOLERANCE = /*#=*/ Numerical.TOLERANCE, - linearSegments; + linearHandles; function resetLinear() { // Reset linear segments if they were part of a linear curve // and if we are done with the entire curve. - for (var i = 0, l = linearSegments.length; i < l; i++) { - var segment = linearSegments[i]; - // FIXME: Don't reset the appropriate handle if the intersection - // was on t == 0 && t == 1. - segment._handleOut.set(0, 0); - segment._handleIn.set(0, 0); + for (var i = 0, l = linearHandles.length; i < l; i++) { + var handle = linearHandles[i]; + handle.set(0, 0); } } @@ -188,10 +185,14 @@ PathItem.inject(new function() { // Scale parameter after previous split. t /= prevLoc._parameter; } else { - if (linearSegments) + if (linearHandles) resetLinear(); curve = loc._curve; - linearSegments = curve.isLinear() && []; + linearHandles = curve.isLinear() && []; + if (linearHandles) { + linearHandles.push(curve._segment1._handleOut); + linearHandles.push(curve._segment2._handleIn); + } } var newCurve, segment; @@ -199,6 +200,10 @@ PathItem.inject(new function() { if (newCurve = curve.divide(t, true, true)) { segment = newCurve._segment1; curve = newCurve.getPrevious(); + if (linearHandles) { + linearHandles.push(segment._handleOut); + linearHandles.push(segment._handleIn); + } } else { segment = t < TOLERANCE ? curve._segment1 @@ -211,11 +216,9 @@ PathItem.inject(new function() { // Link the new segment with the intersection on the other curve segment._intersection = loc.getIntersection(); loc._segment = segment; - if (linearSegments) - linearSegments.push(segment); prevLoc = loc; } - if (linearSegments) + if (linearHandles) resetLinear(); }