Small cleanup in getWinding()

This commit is contained in:
iconexperience 2016-07-13 11:07:12 +02:00
parent 916a712737
commit 46ea9da423

View file

@ -404,7 +404,8 @@ PathItem.inject(new function() {
aAfter = pa + epsilon; aAfter = pa + epsilon;
for (var i = 0, l = curves.length; i < l; i++) { for (var i = 0, l = curves.length; i < l; i++) {
var curve = curves[i]; var curve = curves[i];
if (i === 0 || curves[i - 1].getPath() !== curve.getPath()) { var path = curve.getPath();
if (i === 0 || curves[i - 1].getPath() !== path) {
// On new path, determine values of last non-horizontal curve. // On new path, determine values of last non-horizontal curve.
vPrev = null; vPrev = null;
var curvePrev = curve.getPrevious(); var curvePrev = curve.getPrevious();
@ -445,11 +446,14 @@ PathItem.inject(new function() {
} }
} }
var nextCurve = curves[i + 1]; var nextCurve = curves[i + 1];
if (!nextCurve || nextCurve.getPath() != curve.getPath()) { if (!nextCurve || nextCurve.getPath() != path) {
if (!pathWindings[0] && !pathWindings[1] && isOnPath[0]) { if (!pathWindings[0] && !pathWindings[1] && isOnPath[0]) {
// Use the on-path windings if no other intersections // Use the on-path windings if no other intersections
// were found or if they canceled each other. // were found or if they canceled each other.
onPathWinding += curve.getPath().isClockwise() ? 1 : -1; var incr = path.isClockwise() ? 1 : -1;
windings[0] += incr;
windings[1] += -incr;
onPathWinding += incr;
} else { } else {
windings[0] += pathWindings[0]; windings[0] += pathWindings[0];
windings[1] += pathWindings[1]; windings[1] += pathWindings[1];