From c20b32f748bb4f8a5c341a1e81e0e6dc0eed1ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ju=CC=88rg=20Lehni?= Date: Sun, 4 Jan 2015 22:10:30 +0100 Subject: [PATCH] Implement unit test for #610 --- test/tests/Path_Boolean.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/test/tests/Path_Boolean.js b/test/tests/Path_Boolean.js index 5895e693..dd79989e 100644 --- a/test/tests/Path_Boolean.js +++ b/test/tests/Path_Boolean.js @@ -26,6 +26,30 @@ test('path.unite(); #609', function() { path2.arcTo(new Point(100, 100)); path2.closePath(); - var path3 = path1.unite(path2); - equals(path3.pathData, 'M100,100c27.61424,0 50,22.38576 50,50c0,27.61424 -22.38576,50 -50,50z M100,200c-27.61424,0 -50,-22.38576 -50,-50c0,-27.61424 22.38576,-50 50,-50z', 'path3.pathData'); + var result = path1.unite(path2); + equals(result.pathData, 'M100,100c27.61424,0 50,22.38576 50,50c0,27.61424 -22.38576,50 -50,50z M100,200c-27.61424,0 -50,-22.38576 -50,-50c0,-27.61424 22.38576,-50 50,-50z', 'result.pathData'); +}); + +test('ring.subtract(square); #610', function() { + // https://github.com/paperjs/paper.js/issues/610 + var square = new Path.Rectangle({ + position: [140, 0], + size: 300 + }); + + // Make a ring using subtraction of two circles: + var inner = new Path.Circle({ + center: [0, 0], + radius: 100 + }); + + var outer = new Path.Circle({ + center: [0, 0], + radius: 132 + }); + + var ring = outer.subtract(inner); + var result = ring.subtract(square); + + equals(result.pathData, 'M-10,131.62689c-68.2302,-5.11075 -122,-62.08951 -122,-131.62689c0,-69.53737 53.7698,-126.51614 122,-131.62689l0,32.12064c-50.53323,5.01724 -90,47.65277 -90,99.50625c0,51.85348 39.46677,94.489 90,99.50625z'); });