mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Simplify path filtering code in tracePaths() a bit, and improve documentation.
This commit is contained in:
parent
cb810c73bd
commit
d7be443119
1 changed files with 9 additions and 5 deletions
|
@ -446,11 +446,15 @@ PathItem.inject(new function() {
|
||||||
} else {
|
} else {
|
||||||
path.lastSegment._handleOut.set(0, 0);
|
path.lastSegment._handleOut.set(0, 0);
|
||||||
}
|
}
|
||||||
// Add the path to the result.
|
// Add the path to the result, while avoiding stray segments and
|
||||||
// Try to avoid stray segments and incomplete paths.
|
// incomplete paths. The amount of segments for valid paths depend
|
||||||
var count = path._segments.length;
|
// on their geometry:
|
||||||
if ((path._closed && count) || count > 2
|
// - Closed paths with only straight lines (polygons) need more than
|
||||||
|| (count === 2 && path._closed && !path.isPolygon()))
|
// two segments.
|
||||||
|
// - Closed paths with curves can consist of only one segment.
|
||||||
|
// - Open paths need at least two segments.
|
||||||
|
if (path._segments.length >
|
||||||
|
(path._closed ? path.isPolygon() ? 2 : 0 : 1))
|
||||||
paths.push(path);
|
paths.push(path);
|
||||||
}
|
}
|
||||||
return paths;
|
return paths;
|
||||||
|
|
Loading…
Reference in a new issue