mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-19 14:10:14 -05:00
Merge branch 'refs/heads/bool-cleanup'
This commit is contained in:
commit
21bd4628f2
1 changed files with 18 additions and 7 deletions
|
@ -395,9 +395,15 @@ PathItem.inject(new function() {
|
|||
// countour to traverse next.
|
||||
w3 = t1.cross(t3),
|
||||
w4 = t1.cross(t4);
|
||||
// Do not attempt to switch contours if we aren't absolutely
|
||||
// sure that there is a possible candidate.
|
||||
if (w3 * w4 !== 0) {
|
||||
if (selfOp) {
|
||||
// Switch to the intersection segment, if we are
|
||||
// resolving self-Intersections.
|
||||
seg._visited = interSeg._visited;
|
||||
seg = interSeg;
|
||||
dir = 1;
|
||||
} else if (w3 * w4 !== 0) {
|
||||
// Do not attempt to switch contours if we aren't absolutely
|
||||
// sure that there is a possible candidate.
|
||||
var curve = w3 < w4 ? c3 : c4,
|
||||
nextCurve = operator(curve._segment1._winding)
|
||||
? curve
|
||||
|
@ -440,10 +446,15 @@ PathItem.inject(new function() {
|
|||
} else {
|
||||
path.lastSegment._handleOut.set(0, 0);
|
||||
}
|
||||
// Add the path to the result.
|
||||
// Try to avoid stray segments and incomplete paths.
|
||||
var count = path._segments.length;
|
||||
if (count > 2 || count === 2 && path._closed && !path.isPolygon())
|
||||
// Add the path to the result, while avoiding stray segments and
|
||||
// incomplete paths. The amount of segments for valid paths depend
|
||||
// on their geometry:
|
||||
// - Closed paths with only straight lines (polygons) need more than
|
||||
// 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);
|
||||
}
|
||||
return paths;
|
||||
|
|
Loading…
Reference in a new issue