mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Rename some variables to be more clear about their role.
This commit is contained in:
parent
5e01774c91
commit
bc8fb92b9d
1 changed files with 19 additions and 17 deletions
|
@ -358,22 +358,24 @@ PathItem.inject(new function() {
|
||||||
end = start + curve.length;
|
end = start + curve.length;
|
||||||
// Walk through one single loop of curves.
|
// Walk through one single loop of curves.
|
||||||
var startCounted = false,
|
var startCounted = false,
|
||||||
prevCurve, // non-horizontal curve before the current curve.
|
prevWinding, // The previous non-horizontal curve.
|
||||||
nextCurve, // non-horizontal curve after the current curve.
|
nextWinding, // The next non-horizontal curve (with winding)
|
||||||
prevT = null,
|
prevT = null,
|
||||||
curve = null;
|
curve = null;
|
||||||
for (var i = start; i < end; i++) {
|
for (var i = start; i < end; i++) {
|
||||||
if (!curve) {
|
if (!curve) {
|
||||||
prevCurve = lastWinding;
|
prevWinding = lastWinding;
|
||||||
nextCurve = firstWinding;
|
nextWinding = firstWinding;
|
||||||
} else if (curve.winding) {
|
} else if (curve.winding) {
|
||||||
prevCurve = curve;
|
prevWinding = curve;
|
||||||
}
|
}
|
||||||
curve = curves[i];
|
curve = curves[i];
|
||||||
if (curve === nextCurve) {
|
if (curve === nextWinding) {
|
||||||
nextCurve = curve.next;
|
// Each time we've reached the next curve with winding,
|
||||||
while (nextCurve && !nextCurve.winding) {
|
// search for the next one after.
|
||||||
nextCurve = nextCurve.next;
|
nextWinding = curve.next;
|
||||||
|
while (nextWinding && !nextWinding.winding) {
|
||||||
|
nextWinding = nextWinding.next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var values = curve.values,
|
var values = curve.values,
|
||||||
|
@ -405,10 +407,10 @@ PathItem.inject(new function() {
|
||||||
// Take care of cases where the ray merely touches
|
// Take care of cases where the ray merely touches
|
||||||
// the connecting point between two neighboring mono
|
// the connecting point between two neighboring mono
|
||||||
// curves, but does not cross either of them.
|
// curves, but does not cross either of them.
|
||||||
if (t < tMin && prevCurve
|
if (t < tMin && prevWinding
|
||||||
&& winding * prevCurve.winding < 0
|
&& winding * prevWinding.winding < 0
|
||||||
|| t > tMax && nextCurve
|
|| t > tMax && nextWinding
|
||||||
&& winding * nextCurve.winding < 0) {
|
&& winding * nextWinding.winding < 0) {
|
||||||
if (x > xBefore && x < xAfter) {
|
if (x > xBefore && x < xAfter) {
|
||||||
++windLeft;
|
++windLeft;
|
||||||
++windRight;
|
++windRight;
|
||||||
|
@ -431,11 +433,11 @@ PathItem.inject(new function() {
|
||||||
// If the point is on a horizontal curve and winding
|
// If the point is on a horizontal curve and winding
|
||||||
// changes between before and after the curve, we treat
|
// changes between before and after the curve, we treat
|
||||||
// this as a 'touch point'.
|
// this as a 'touch point'.
|
||||||
if (py === values[1]
|
if (prevWinding && nextWinding
|
||||||
&& (values[0] < xAfter && values[6] > xBefore
|
&& py === values[1]
|
||||||
|
&& (values[0] < xAfter && values[6] > xBefore
|
||||||
|| values[6] < xAfter && values[0] > xBefore)
|
|| values[6] < xAfter && values[0] > xBefore)
|
||||||
&& prevCurve && nextCurve
|
&& prevWinding.winding * nextWinding.winding < 0) {
|
||||||
&& prevCurve.winding * nextCurve.winding < 0) {
|
|
||||||
++windLeft;
|
++windLeft;
|
||||||
++windRight;
|
++windRight;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue