diff --git a/test/tests/Path_Boolean.js b/test/tests/Path_Boolean.js index 54378e60..04739bcf 100644 --- a/test/tests/Path_Boolean.js +++ b/test/tests/Path_Boolean.js @@ -686,6 +686,19 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function( [560, 300, 0, 0, 0, 0], [522.421811145802, 296.21971842903645, 0, 0, 0, 0] ] + ], [ + [ + [87.34388521634615, 0, -3.9382371300724373, 0, 2.1330446378301247, 0], + [93.61538461538461, 0, -2.9185159236061224, 0, 2.2538650858334677, 0], + [100.17943209134619, 0, -2.11714516843503, 0, 8.39247295673077, 0], + [100.17943209134613, 0, -4.131239081724743, 0, -2.1880158253205195, 0], + [93.61538461538458, 0, 2.1880158253205053, 0, -2.0904997996794776, 0] + ], [ + [163.8269230769231, 0, 0, 0, 0, 0], + [160.90144230769232, 0, 1.6090144230769283, 0, 0, 0], + [2.9254807692307696, 0, 0, 0, -1.6090144230769234, 0], + [0, 0, 0, 0, 0, 0] + ] ]]; var results = [ ['M450,230l-87.53067,34.43944l-0.01593,-0.02371c-0.91969,-0.32388 -30.35274,-0.48069 -30.67835,2.89141l-2.76789,-52.67014z', ''], @@ -715,7 +728,8 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function( ['M525,345l32.31797,18.04379l23.72504,-18.37449l6.0793,21.87157l-87.1223,33.45913z', 'M557.31797,363.04379l-23.71188,18.3643l-6.07498,-21.85933z'], ['M250,150l-15.25375,32.05024l-8.90311,-28.94542l-45.84314,36.89518l63.48255,20.45333l-8.7363,-28.40309l29.10275,-7.1942z', 'M205.61256,189.25209l-0.01028,0.00254l0,0.2z'], ['M598.5487,408.11025l-42.28034,59.10612l-37.73535,-87.53938l36.05709,27.56285l0.78705,28.12706z', 'M552.42922,437.2281l2.94792,-1.86119l0.89121,31.84947z'], - ['M570,290l2.68132,15.47954l6.15287,-0.90118c0,0 -2.36581,0.34651 -6.15287,0.90118l3.13628,18.10603l-28.17314,-14.439c-14.32289,2.0978 -28.17688,4.12693 -28.17688,4.12693l19.08162,-8.78834l-16.12739,-8.26544l27.9654,2.81326z M564.48039,306.68069c-2.28529,0.33471 3.11282,-0.45592 0,0z', 'M575.8176,323.58557l-28.17314,-14.439l16.83593,-2.46588z M564.48039,306.68069c-5.08619,0.74495 -10.99999,1.61111 -16.83593,2.46588c-14.32289,2.0978 -28.17688,4.12693 -28.17688,4.12693l30.91963,-14.24052l9.61279,0.96702z'] + ['M570,290l2.68132,15.47954l6.15287,-0.90118c0,0 -2.36581,0.34651 -6.15287,0.90118l3.13628,18.10603l-28.17314,-14.439c-14.32289,2.0978 -28.17688,4.12693 -28.17688,4.12693l19.08162,-8.78834l-16.12739,-8.26544l27.9654,2.81326z M564.48039,306.68069c-2.28529,0.33471 3.11282,-0.45592 0,0z', 'M575.8176,323.58557l-28.17314,-14.439l16.83593,-2.46588z M564.48039,306.68069c-5.08619,0.74495 -10.99999,1.61111 -16.83593,2.46588c-14.32289,2.0978 -28.17688,4.12693 -28.17688,4.12693l30.91963,-14.24052l9.61279,0.96702z'], + ['', ''] ]; for (var i = 0; i < data.length; i++) { var entry = data[i], @@ -725,4 +739,75 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function( compareBoolean(path1.unite(path2), result[0], 'path1.unite(path2); // Test ' + (i + 1)); compareBoolean(path1.intersect(path2), result[1], 'path1.intersect(path2); // Test ' + (i + 1)); } + + // https://github.com/paperjs/paper.js/issues/784#issuecomment-144653463 + var path1 = new Path({ + segments: [ + [400, 300, 0, 0, 0, 0], + [396.4240965757225, 386.760212367686, 0, 0, 0, 0], + [363.8902430603039, 336.3464406833805, 0, 0, 0, 0] + ], + closed: true + }); + var path2 = new Path({ + segments: [ + [380.15716053320796, 361.5533174872367, 0, 0, 0, 0], + [368.9579765078272, 389.3845783631412, 0, 0, 0, 0], + [352.11749924000907, 372.22000125020173, 0, 0, 0, 0] + ], + closed: true + }); + var path3 = new Path({ + segments: [ + [381.9248139754118, 360.88087710036456, 0, 0, 0, 0], + [352.11749931845384, 372.22000145641056, 0, 0, 0, 0], + [353.8723170322086, 346.9400510828104, 0, 0, 0, 0] + ], + closed: true + }); + compareBoolean(function() { return path1.unite(path2).unite(path3); }, + 'M400,300l-3.5759,86.76021l-16.26693,-25.2069l0,0l-11.19918,27.83126l-16.84048,-17.16458l1.75482,-25.27995l24.8115,12.3302l-14.79357,-22.92381z M352.1175,372.22z'); + + + // https://github.com/paperjs/paper.js/issues/784#issuecomment-144993215 + var path1 = new Path({ + segments: [ + [428.65986693122585, 123.24312916360232, 0, 0, 0, 0], + [448.9732353341095, 290.23336023178985, -1.297313778199964, -0.24666929481787747, -0.06896642337790126, -0.004714867204086204], + [448.9732339473677, 290.2333601369859, 0.22704183013848933, 0.04316939284507271, 0.24127512029406262, 0.016494695478172616], + [375.34013306877415, 150.7568708363977, 0, 0, 0, 0] + ], + closed: true + }); + compareBoolean(function() { return path1.unite(); }, + 'M428.65987,123.24313c0,0 18.24445,159.97772 20.21157,166.76806c-3.05664,-6.18082 -73.53131,-139.25432 -73.53131,-139.25432z M448.97323,290.23336c0,0 0,0 0,0c0.22704,0.04317 -0.06896,-0.00471 0,0c-0.02659,-0.00506 -0.06063,-0.08007 -0.1018,-0.22217c0.07286,0.14733 0.10741,0.22256 0.1018,0.22217z'); + + // https://github.com/paperjs/paper.js/issues/784#issuecomment-168605018 + var path1 = new CompoundPath(); + path1.setChildren([ + new Path({ + segments: [ + [401.77542835664826, 286.9803609495646], + [410.6261525310172, 207.97354059345616], + [460.3783408790767, 174.43669899386418], + ], + closed: true + }), new Path({ + segments: [ + [410.6261524612045, 207.9735406405153], + [410.6261525310172, 207.97354059345614, -0.0005059167983745283, -0.0007686158121771314] + ], + closed: true + }) + ], true); + var path2 = new Path({ + segments: [ + [410.6261524612047, 207.97354064051552, 0, 0, 0.19904749518872222, 0.2952886437272184], + [409.163896522797, 207.2586618457598, 1.6828473498011363, 0.6114523237241087], + [460.3783408790765, 174.43669899386396] + ], + closed: true + }); + compareBoolean(function() { return path1.unite(path2); }, + 'M401.77543,286.98036l8.85044,-79.00432c-0.16499,-0.13413 -0.57872,-0.39645 -1.46198,-0.71738l51.21444,-32.82196z M410.62615,207.97354c0,0 0,0 0,0z'); });