From 26bf4f4749bf255646893314baf4ce727f807fec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Wed, 8 Mar 2017 15:55:51 +0100 Subject: [PATCH] Change getWinding() to include recommendation by @iconexperience See https://github.com/paperjs/paper.js/issues/1261#issuecomment-283325168 Closes #1261 --- src/path/PathItem.Boolean.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 03a36fbd..a31840a1 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -512,13 +512,17 @@ PathItem.inject(new function() { // Bail out without updating vPrev at the end of the call. return; } + // Determine the curve-time value corresponding to the point. var t = po === o0 ? 0 : po === o3 ? 1 + // If the abscissa is outside the curve, we can use any + // value except 0 (requires special handling). Use 1, as it + // does not require additional calculations for the point. : paL > max(a0, a1, a2, a3) || paR < min(a0, a1, a2, a3) ? 1 - : Curve.solveCubic(v, io, po, roots, 0, 1) === 1 + : Curve.solveCubic(v, io, po, roots, 0, 1) > 0 ? roots[0] - : 0.5, + : 1, a = t === 0 ? a0 : t === 1 ? a3 : Curve.getPoint(v, t)[dir ? 'y' : 'x'],