mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
Implement correct behavior for intersection, subtraction and intersection of fully overlapping paths.
This commit is contained in:
parent
ba6c1201fe
commit
3c66c013d1
2 changed files with 19 additions and 10 deletions
|
@ -138,9 +138,12 @@ PathItem.inject(new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If all encountered are overlaps (regardless if valid or not), we have
|
// If all encountered are overlaps (regardless if valid or not), we have
|
||||||
// two fully overlapping paths and can just return a clone of the first.
|
// two fully overlapping paths and can just return a clone of the first,
|
||||||
|
// or an empty path, depending on the operation.
|
||||||
return finishResult(overlapsOnly
|
return finishResult(overlapsOnly
|
||||||
? path1.getArea() ? path1.clone() : new Path(Item.NO_INSERT)
|
? (operator.unite || operator.intersect) && path1.getArea()
|
||||||
|
? path1.clone(false)
|
||||||
|
: new Path(Item.NO_INSERT)
|
||||||
: createResult(CompoundPath,
|
: createResult(CompoundPath,
|
||||||
tracePaths(segments, operator, validOverlapsOnly),
|
tracePaths(segments, operator, validOverlapsOnly),
|
||||||
!overlapsOnly), path1, path2);
|
!overlapsOnly), path1, path2);
|
||||||
|
|
|
@ -296,13 +296,15 @@ test('#877', function() {
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
|
|
||||||
var p = new Path({segments:[
|
var p = new Path({
|
||||||
[135, 200],
|
segments: [
|
||||||
[135, 120],
|
[135, 200],
|
||||||
[170, 120],
|
[135, 120],
|
||||||
[170, 200]
|
[170, 120],
|
||||||
], closed:true});
|
[170, 200]
|
||||||
|
],
|
||||||
|
closed: true
|
||||||
|
});
|
||||||
compareBoolean(function() { return cp.subtract(p); },
|
compareBoolean(function() { return cp.subtract(p); },
|
||||||
'M50,60c0,-27.61424 22.38576,-50 50,-50c27.61424,0 50,22.38576 50,50c0,27.61424 -22.38576,50 -50,50c-27.61424,0 -50,-22.38576 -50,-50z M100,90c16.56854,0 30,-13.43146 30,-30c0,-16.56854 -13.43146,-30 -30,-30c-16.56854,0 -30,13.43146 -30,30c0,16.56854 13.43146,30 30,30z M120,140l15,0l0,50l-15,0z');
|
'M50,60c0,-27.61424 22.38576,-50 50,-50c27.61424,0 50,22.38576 50,50c0,27.61424 -22.38576,50 -50,50c-27.61424,0 -50,-22.38576 -50,-50z M100,90c16.56854,0 30,-13.43146 30,-30c0,-16.56854 -13.43146,-30 -30,-30c-16.56854,0 -30,13.43146 -30,30c0,16.56854 13.43146,30 30,30z M120,140l15,0l0,50l-15,0z');
|
||||||
});
|
});
|
||||||
|
@ -318,9 +320,13 @@ test('#878', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('#885', function() {
|
test('#885', function() {
|
||||||
var p1 = new paper.Path.Rectangle(100, 100, 100, 100);
|
var p1 = new Path.Rectangle(100, 100, 100, 100);
|
||||||
var p2 = p1.clone();
|
var p2 = p1.clone();
|
||||||
|
var empty = new Path();
|
||||||
compareBoolean(function() { return p1.unite(p2); }, p1);
|
compareBoolean(function() { return p1.unite(p2); }, p1);
|
||||||
|
compareBoolean(function() { return p1.intersect(p2); }, p1);
|
||||||
|
compareBoolean(function() { return p1.subtract(p2); }, empty);
|
||||||
|
compareBoolean(function() { return p1.exclude(p2); }, empty);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('#889 & #890', function() {
|
test('#889 & #890', function() {
|
||||||
|
|
Loading…
Reference in a new issue