mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Boolean: No need to actually check for fill
This commit is contained in:
parent
192437dbe2
commit
2ef8175cb8
2 changed files with 10 additions and 12 deletions
|
@ -61,12 +61,12 @@ PathItem.inject(new function() {
|
|||
.clone(false)
|
||||
.reduce({ simplify: true })
|
||||
.transform(null, true, true);
|
||||
// For correct results, close open filled paths with straight lines:
|
||||
if (resolve && res.hasFill()) {
|
||||
if (resolve) {
|
||||
// For correct results, close open paths with straight lines:
|
||||
var paths = getPaths(res);
|
||||
for (var i = 0, l = paths.length; i < l; i++) {
|
||||
var path = paths[i];
|
||||
if (!path._closed) {
|
||||
if (!path._closed && !path.isEmpty()) {
|
||||
// Close with epsilon tolerance, to avoid tiny straight
|
||||
// that would cause issues with intersection detection.
|
||||
path.closePath(/*#=*/Numerical.EPSILON);
|
||||
|
@ -74,12 +74,11 @@ PathItem.inject(new function() {
|
|||
path.getLastSegment().setHandleOut(0, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return resolve
|
||||
? res
|
||||
res = res
|
||||
.resolveCrossings()
|
||||
.reorient(res.getFillRule() === 'nonzero', true)
|
||||
: res;
|
||||
.reorient(res.getFillRule() === 'nonzero', true);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
function createResult(paths, simplify, path1, path2, options) {
|
||||
|
|
|
@ -888,7 +888,7 @@ test('#1221', function() {
|
|||
compareBoolean(function() { return blob.subtract(rect2, { trace: false }); },
|
||||
'M534,273c-29.65069,-13.2581 -57.61955,-25.39031 -84,-36.46967M150,138.13156c-71.67127,-11.53613 -105.25987,0.10217 -120,19.86844c-40.5,54.3 31.5,210.2 111,222c3.08303,0.45637 6.07967,0.68158 9,0.69867M409.85616,400c18.87105,20.95032 39.82014,38.41763 69.14384,42c33.8,4.1 83.1,-9.7 150,-90');
|
||||
compareBoolean(function() { return blob.subtract(rect2, { trace: true }); },
|
||||
'M629,352c-66.9,80.3 -116.2,94.1 -150,90c-29.3237,-3.58237 -50.27279,-21.04968 -69.14384,-42h40.14384v-163.46967c26.38045,11.07937 54.34931,23.21157 84,36.46967M141,380c-79.5,-11.8 -151.5,-167.7 -111,-222c14.74013,-19.76627 48.32873,-31.40457 120,-19.86844v242.56712c-2.92033,-0.01709 -5.91697,-0.24231 -9,-0.69867z');
|
||||
'M629,352c-66.9,80.3 -116.2,94.1 -150,90c-29.3237,-3.58237 -50.27279,-21.04968 -69.14384,-42h40.14384v-163.46967c26.38045,11.07937 54.34931,23.21157 84,36.46967zM141,380c-79.5,-11.8 -151.5,-167.7 -111,-222c14.74013,-19.76627 48.32873,-31.40457 120,-19.86844v242.56712c-2.92033,-0.01709 -5.91697,-0.24231 -9,-0.69867z');
|
||||
|
||||
var rect3 = new Path.Rectangle({
|
||||
point: [150, 100],
|
||||
|
@ -898,8 +898,7 @@ test('#1221', function() {
|
|||
compareBoolean(function() { return blob.subtract(rect3, { trace: false }); },
|
||||
'M534,273c-29.65069,-13.2581 -57.61955,-25.39031 -84,-36.46967M150,138.13156c-71.67127,-11.53613 -105.25987,0.10217 -120,19.86844c-40.5,54.3 31.5,210.2 111,222c60.8,9 88,-71.9 159,-66c81.6,6.8 99.6,118.3 179,128c33.8,4.1 83.1,-9.7 150,-90');
|
||||
compareBoolean(function() { return blob.subtract(rect3, { trace: true }); },
|
||||
'M629,352c-66.9,80.3 -116.2,94.1 -150,90c-79.4,-9.7 -97.4,-121.2 -179,-128c-71,-5.9 -98.2,75 -159,66c-79.5,-11.8 -151.5,-167.7 -111,-222c14.74013,-19.76627 48.32873,-31.40457 120,-19.86844v111.86844h300v-13.46967c26.38045,11.07937 54.34931,23.21157 84,36.46967');
|
||||
|
||||
'M629,352c-66.9,80.3 -116.2,94.1 -150,90c-79.4,-9.7 -97.4,-121.2 -179,-128c-71,-5.9 -98.2,75 -159,66c-79.5,-11.8 -151.5,-167.7 -111,-222c14.74013,-19.76627 48.32873,-31.40457 120,-19.86844v111.86844h300v-13.46967c26.38045,11.07937 54.34931,23.21157 84,36.46967z');
|
||||
|
||||
var rect4 = new Path.Rectangle({
|
||||
point: [200, 200],
|
||||
|
@ -1219,7 +1218,7 @@ test('#1419', function() {
|
|||
test('#1351', function() {
|
||||
var path1 = new CompoundPath(new Path([10, 10], [100, 100]), new Path([150, 25]));
|
||||
var path2 = new Path([20, 80], [80, 20]);
|
||||
var result = 'M10,10l40,40l50,50';
|
||||
var result = ''; // empty!
|
||||
compareBoolean(path1.unite(path2), result);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue