mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-06 04:42:15 -05:00
Boolean: Handle situations where seg.getNext() can be null.
Closes #1056
This commit is contained in:
parent
742401a0e1
commit
28543deaf5
1 changed files with 8 additions and 7 deletions
|
@ -504,7 +504,8 @@ PathItem.inject(new function() {
|
||||||
// also part of the contour of the result. Such segments are not
|
// also part of the contour of the result. Such segments are not
|
||||||
// chosen as the start of new paths and are not always counted as a
|
// chosen as the start of new paths and are not always counted as a
|
||||||
// valid next step, as controlled by the excludeContour parameter.
|
// valid next step, as controlled by the excludeContour parameter.
|
||||||
return !!(!seg._visited && (!operator || operator[seg._winding]
|
return !!(seg && !seg._visited && (!operator
|
||||||
|
|| operator[seg._winding]
|
||||||
|| !excludeContour && operator.unite && seg._contour));
|
|| !excludeContour && operator.unite && seg._contour));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,7 +522,7 @@ PathItem.inject(new function() {
|
||||||
while (inter) {
|
while (inter) {
|
||||||
var seg = inter._segment,
|
var seg = inter._segment,
|
||||||
nextSeg = seg.getNext(),
|
nextSeg = seg.getNext(),
|
||||||
nextInter = nextSeg._intersection;
|
nextInter = nextSeg && nextSeg._intersection;
|
||||||
// See if this segment and the next are both not visited yet, or
|
// See if this segment and the next are both not visited yet, or
|
||||||
// are bringing us back to the beginning, and are both valid,
|
// are bringing us back to the beginning, and are both valid,
|
||||||
// meaning they are part of the boolean result.
|
// meaning they are part of the boolean result.
|
||||||
|
@ -646,11 +647,11 @@ PathItem.inject(new function() {
|
||||||
path.setClosed(true);
|
path.setClosed(true);
|
||||||
} else if (path) {
|
} else if (path) {
|
||||||
// Only complain about open paths if they would actually contain
|
// Only complain about open paths if they would actually contain
|
||||||
// an area when closed. Such open paths can occur due to
|
// an area when closed. Open paths that can silently discarded
|
||||||
// epsilons, e.g. when two segments are so close to each other
|
// can occur due to epsilons, e.g. when two segments are so
|
||||||
// that they are considered the same, but the winding
|
// close to each other that they are considered the same
|
||||||
// calculation still produces a valid winding due to their
|
// location, but the winding calculation still produces a valid
|
||||||
// slight differences.
|
// number due to their slight differences producing a tiny area.
|
||||||
var area = path.getArea(true);
|
var area = path.getArea(true);
|
||||||
if (Math.abs(area) >= /*#=*/Numerical.GEOMETRIC_EPSILON) {
|
if (Math.abs(area) >= /*#=*/Numerical.GEOMETRIC_EPSILON) {
|
||||||
// This path wasn't finished and is hence invalid.
|
// This path wasn't finished and is hence invalid.
|
||||||
|
|
Loading…
Reference in a new issue