mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Clean up code formatting.
This commit is contained in:
parent
8928eaffd0
commit
5d875f2d83
1 changed files with 24 additions and 23 deletions
|
@ -297,7 +297,8 @@ PathItem.inject(new function() {
|
||||||
values = curve.values,
|
values = curve.values,
|
||||||
winding = curve.winding,
|
winding = curve.winding,
|
||||||
next = curve.next,
|
next = curve.next,
|
||||||
lastT, lastX0;
|
lastT,
|
||||||
|
lastX0;
|
||||||
// Since the curves are monotone in y direction, we can just
|
// Since the curves are monotone in y direction, we can just
|
||||||
// compare the endpoints of the curve to determine if the
|
// compare the endpoints of the curve to determine if the
|
||||||
// ray from query point along +-x direction will intersect
|
// ray from query point along +-x direction will intersect
|
||||||
|
@ -305,33 +306,33 @@ PathItem.inject(new function() {
|
||||||
if (winding && (winding === 1
|
if (winding && (winding === 1
|
||||||
&& y >= values[1] && y <= values[7]
|
&& y >= values[1] && y <= values[7]
|
||||||
|| y >= values[7] && y <= values[1])
|
|| y >= values[7] && y <= values[1])
|
||||||
&& Curve.solveCubic(values, 1, y, roots, 0, 1) === 1){
|
&& Curve.solveCubic(values, 1, y, roots, 0, 1) === 1) {
|
||||||
var t = roots[0],
|
var t = roots[0],
|
||||||
x0 = Curve.evaluate(values, t, 0).x,
|
x0 = Curve.evaluate(values, t, 0).x,
|
||||||
slope = Curve.evaluate(values, t, 1).y;
|
slope = Curve.evaluate(values, t, 1).y;
|
||||||
// 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 && abs(lastX0 - x0) < tolerance
|
if (!(lastT !== null && abs(lastX0 - x0) < tolerance
|
||||||
&& ((lastT <= tMin && t >= tMax)
|
&& (lastT <= tMin && t >= tMax
|
||||||
|| (t <= tMin && lastT >= tMax)))) {
|
|| t <= tMin && lastT >= tMax))) {
|
||||||
// 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, but
|
// curve merely touches the ray towards +-x direction,
|
||||||
// proceeds to the same side of the ray. This essentially is
|
// but proceeds to the same side of the ray.
|
||||||
// not a crossing.
|
// This essentially is not a crossing.
|
||||||
if (Numerical.isZero(slope) && !Curve.isLinear(values)
|
if (Numerical.isZero(slope) && !Curve.isLinear(values)
|
||||||
|| t < tMin && slope * Curve.evaluate(
|
|| t < tMin && slope * Curve.evaluate(
|
||||||
curve.previous.values, t, 1).y < 0) {
|
curve.previous.values, t, 1).y < 0) {
|
||||||
if (testContains && x0 >= xBefore && x0 <= xAfter) {
|
if (testContains && x0 >= xBefore && x0 <= xAfter) {
|
||||||
++windLeft;
|
++windLeft;
|
||||||
++windRight;
|
++windRight;
|
||||||
|
}
|
||||||
|
} else if (x0 <= xBefore) {
|
||||||
|
windLeft += winding;
|
||||||
|
} else if (x0 >= xAfter) {
|
||||||
|
windRight += winding;
|
||||||
}
|
}
|
||||||
} else if (x0 <= xBefore) {
|
|
||||||
windLeft += winding;
|
|
||||||
} else if (x0 >= xAfter) {
|
|
||||||
windRight += winding;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lastT = t;
|
lastT = t;
|
||||||
lastX0 = x0;
|
lastX0 = x0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue