mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-07-27 22:29:11 -04:00
Fix the rest of the failing tests that 6c6ad76c94
had caused.
Also closes #610.
This commit is contained in:
parent
5f3df1f5a1
commit
72bd150a34
1 changed files with 18 additions and 5 deletions
|
@ -297,6 +297,7 @@ PathItem.inject(new function() {
|
||||||
values = curve.values,
|
values = curve.values,
|
||||||
winding = curve.winding,
|
winding = curve.winding,
|
||||||
next = curve.next,
|
next = curve.next,
|
||||||
|
lastCurve,
|
||||||
lastT,
|
lastT,
|
||||||
lastX0;
|
lastX0;
|
||||||
// Since the curves are monotone in y direction, we can just
|
// Since the curves are monotone in y direction, we can just
|
||||||
|
@ -313,7 +314,18 @@ PathItem.inject(new function() {
|
||||||
// Due to numerical precision issues, two consecutive curves
|
// Due to numerical precision issues, two consecutive curves
|
||||||
// may register an intercept twice, at t = 1 and 0, if y is
|
// may register an intercept twice, at t = 1 and 0, if y is
|
||||||
// almost equal to one of the endpoints of the curves.
|
// almost equal to one of the endpoints of the curves.
|
||||||
if (!(lastT != null && abs(lastX0 - x0) < tolerance
|
// But since curves may contain more than one loop of curves
|
||||||
|
// and the end point on the last curve of a loop would not
|
||||||
|
// be registered as a double, we need to filter these cases:
|
||||||
|
if (!(t > tMax
|
||||||
|
// Detect and exclude intercepts at 'end' of loops:
|
||||||
|
&& (i === l - 1 || curve.next !== curves[i + 1])
|
||||||
|
&& abs(Curve.evaluate(curve.next.values, 0, 0).x
|
||||||
|
- x0) <= tolerance
|
||||||
|
// Detect 2nd case of a consecutive intercept, but make
|
||||||
|
// sure we're still on the same loop
|
||||||
|
|| lastCurve === curve.previous
|
||||||
|
&& abs(lastX0 - x0) < tolerance
|
||||||
&& lastT > tMax && t < tMin)) {
|
&& lastT > tMax && t < tMin)) {
|
||||||
// Take care of cases where the curve and the preceding
|
// Take care of cases where the curve and the preceding
|
||||||
// curve merely touches the ray towards +-x direction,
|
// curve merely touches the ray towards +-x direction,
|
||||||
|
@ -336,6 +348,7 @@ PathItem.inject(new function() {
|
||||||
windRight += winding;
|
windRight += winding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
lastCurve = curve;
|
||||||
lastT = t;
|
lastT = t;
|
||||||
lastX0 = x0;
|
lastX0 = x0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue