Change getWinding() to include recommendation by @iconexperience

See https://github.com/paperjs/paper.js/issues/1261#issuecomment-283325168

Closes #1261
This commit is contained in:
Jürg Lehni 2017-03-08 15:55:51 +01:00
parent cbc873cfd8
commit 26bf4f4749

View file

@ -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'],