mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -05:00
Actually use selfOp argument for self operations.
Appears to be working fine.
This commit is contained in:
parent
e242634011
commit
7ca8ce3cbb
1 changed files with 12 additions and 9 deletions
|
@ -199,7 +199,8 @@ PathItem.inject(new function() {
|
||||||
}
|
}
|
||||||
// Trace closed contours and insert them into the result.
|
// Trace closed contours and insert them into the result.
|
||||||
var result = new CompoundPath(Item.NO_INSERT);
|
var result = new CompoundPath(Item.NO_INSERT);
|
||||||
result.addChildren(tracePaths(segments, monoCurves, operation), true);
|
result.addChildren(tracePaths(segments, monoCurves, operation, !_path2),
|
||||||
|
true);
|
||||||
// See if the CompoundPath can be reduced to just a simple Path.
|
// See if the CompoundPath can be reduced to just a simple Path.
|
||||||
result = result.reduce();
|
result = result.reduce();
|
||||||
result.insertAbove(path1);
|
result.insertAbove(path1);
|
||||||
|
@ -496,7 +497,7 @@ PathItem.inject(new function() {
|
||||||
// If the intersection segment is valid, try switching to
|
// If the intersection segment is valid, try switching to
|
||||||
// it, with an appropriate direction to continue traversal.
|
// it, with an appropriate direction to continue traversal.
|
||||||
// Else, stay on the same contour.
|
// Else, stay on the same contour.
|
||||||
if (added && (!operator(seg._winding) || selfOp)
|
if (added && (selfOp || !operator(seg._winding))
|
||||||
&& (inter = seg._intersection)
|
&& (inter = seg._intersection)
|
||||||
&& (interSeg = inter._segment)
|
&& (interSeg = inter._segment)
|
||||||
&& interSeg !== startSeg) {
|
&& interSeg !== startSeg) {
|
||||||
|
@ -577,17 +578,19 @@ PathItem.inject(new function() {
|
||||||
// Move to the next segment according to the traversal direction
|
// Move to the next segment according to the traversal direction
|
||||||
seg = dir > 0 ? seg.getNext() : seg. getPrevious();
|
seg = dir > 0 ? seg.getNext() : seg. getPrevious();
|
||||||
if (reportSegments) {
|
if (reportSegments) {
|
||||||
console.log(seg, !seg._visited,
|
console.log(seg, seg && !seg._visited,
|
||||||
seg !== startSeg, seg !== startInterSeg,
|
seg !== startSeg, seg !== startInterSeg,
|
||||||
seg._intersection, operator(seg._winding));
|
seg && seg._intersection, seg && operator(seg._winding));
|
||||||
if (!(seg && !seg._visited
|
if (!(seg && !seg._visited
|
||||||
&& seg !== startSeg && seg !== startInterSeg
|
&& seg !== startSeg && seg !== startInterSeg
|
||||||
&& (seg._intersection || operator(seg._winding)))) {
|
&& (seg._intersection || operator(seg._winding)))) {
|
||||||
new Path.Circle({
|
if (seg) {
|
||||||
center: seg.point,
|
new Path.Circle({
|
||||||
radius: 4,
|
center: seg.point,
|
||||||
fillColor: 'red'
|
radius: 4,
|
||||||
});
|
fillColor: 'red'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (seg && !seg._visited
|
} while (seg && !seg._visited
|
||||||
|
|
Loading…
Reference in a new issue