diff --git a/src/path/PathItem.Boolean.js b/src/path/PathItem.Boolean.js index 314e0e96..6bebd80d 100644 --- a/src/path/PathItem.Boolean.js +++ b/src/path/PathItem.Boolean.js @@ -138,9 +138,12 @@ PathItem.inject(new function() { } } // 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 - ? 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, tracePaths(segments, operator, validOverlapsOnly), !overlapsOnly), path1, path2); diff --git a/test/tests/Path_Boolean.js b/test/tests/Path_Boolean.js index dbf434cb..505fb722 100644 --- a/test/tests/Path_Boolean.js +++ b/test/tests/Path_Boolean.js @@ -296,13 +296,15 @@ test('#877', function() { }) ]); - var p = new Path({segments:[ - [135, 200], - [135, 120], - [170, 120], - [170, 200] - ], closed:true}); - + var p = new Path({ + segments: [ + [135, 200], + [135, 120], + [170, 120], + [170, 200] + ], + closed: true + }); 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'); }); @@ -318,9 +320,13 @@ test('#878', 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 empty = new Path(); 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() {