From 36a98706b3925dc2430d7a3903e10eff80dcb3c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 7 Jan 2016 15:58:51 +0100 Subject: [PATCH] Use epsilons when deciding for horizontal winding and dealing with horizontal mono-curves. Relates to #890#issuecomment-169672571, fixing the 2nd case of the 2nd example. --- src/path/PathItem.Boolean.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 88886a53..292a705f 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -434,7 +434,7 @@ PathItem.inject(new function() { // changes between before and after the curve, we treat // this as a 'touch point'. if (prevWinding && nextWinding - && py === values[1] + && abs(py - values[1]) < epsilon && (values[0] < xAfter && values[6] > xBefore || values[6] < xAfter && values[0] > xBefore) && prevWinding.winding * nextWinding.winding < 0) { @@ -937,7 +937,10 @@ Path.inject(/** @lends Path# */{ function insertCurve(v) { var y0 = v[1], y1 = v[7], - winding = y0 === y1 + // Look at the slope of the line between the mono-curve's anchor + // points with some tolerance to decide if it is horizontal. + winding = Math.abs((y0 - y1) / (v[0] - v[6])) + < /*#=*/Numerical.GEOMETRIC_EPSILON ? 0 // Horizontal : y0 > y1 ? -1 // Decreasing