mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Address proposal by @iconexperience in #869 and shorten code.
Closes #877
This commit is contained in:
parent
511fc12dd4
commit
92904e95c2
1 changed files with 10 additions and 8 deletions
|
@ -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',
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue