Skip to content

Commit

Permalink
Address proposal by @iconexperience in #869 and shorten code.
Browse files Browse the repository at this point in the history
Closes #877
  • Loading branch information
lehni committed Dec 30, 2015
1 parent 511fc12 commit 92904e9
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/path/PathItem.Boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,6 @@ PathItem.inject(new function() {
return b.getBounds().getArea() - a.getBounds().getArea();
});
var first = paths[0],
clockwise = first.isClockwise(),
items = [first],
excluded = {},
isNonZero = this.getFillRule() === 'nonzero',
Expand All @@ -820,8 +819,9 @@ PathItem.inject(new function() {
var path = paths[i],
point = path.getInteriorPoint(),
isContained = false,
container = null,
exclude = false;
for (var j = i - 1; j >= 0; j--) {
for (var j = i - 1; j >= 0 && !container; j--) {
// We run through the paths from largest to smallest,
// meaning that for any current path, all potentially
// containing paths have already been processed and
Expand All @@ -841,15 +841,17 @@ PathItem.inject(new function() {
}
}
isContained = true;
if (!excluded[j]) {
// Set opposite orientation of containing path.
clockwise = !paths[j].isClockwise();
break;
}
// If the containing path is not excluded, we're
// done searching for the orientation defining path.
container = !excluded[j] && paths[j];
}
}
if (!exclude) {
path.setClockwise(clockwise);
// Set to the opposite orientation of containing path,
// or the same orientation as the first path if the path
// is not contained in any other path.
path.setClockwise(container ? !container.isClockwise()
: first.isClockwise());
items.push(path);
}
}
Expand Down

0 comments on commit 92904e9

Please sign in to comment.