mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-01 02:38:43 -05:00
parent
28543deaf5
commit
ea5a635edf
1 changed files with 25 additions and 14 deletions
|
@ -977,6 +977,12 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
|
|||
[2.9254807692307696, 0, 0, 0, -1.6090144230769234, 0],
|
||||
[0, 0, 0, 0, 0, 0]
|
||||
]
|
||||
], [
|
||||
'M419.20344565830516,384.34607379092466c5.844713611412715,3.313058909545532 8.737629565616828,3.6008009941920136 9.663847696961,3.5457774486854987c0.4249875971154893,-0.23215482613579752 3.134401138218834,-1.9001699951828073 6.912521889816844,-9.027614775318739c33.358079343370036,-62.930193110079074 15.048818377810562,-263.53585410399967 14.89110904614597,-264.2035689431943l58.39331120497843,-13.792070421750992c0.38461989956749676,1.6284160973869177 24.314056080847877,221.98511298279283 -20.271816008415897,306.09659649109955c-7.779727674038611,14.676497403570863 -19.843728834889646,29.87171953249475 -38.60350857895327,37.0189975138764c-20.692089248499826,7.88346749760683 -41.830098370105475,3.183730282850888 -60.57334789311045,-7.440826188961864z',
|
||||
'M450.6709242911992,114.66066752097116c-5.7317866225195075,-24.267422495749997 -2.0221968032280984,26.377626042706837 32.186077599051714,22.94975715794014l-5.982390225081872,-59.70101345199127c34.20913357233178,-3.427954978623788 37.91990661944476,47.22024138695528 32.18962383106816,22.95918587255207z'
|
||||
], [
|
||||
'M224.25080140147438,238.4376691273944c2.4512375314882604,34.92470808870988 9.866473254030097,54.13389818714606 17.201166692275166,64.07401871051215c4.079846680080152,5.529088305912239 8.23969086685824,8.377993223423289 12.35501848826604,9.971618948612331c7.68049930207755,2.9742082274120776 19.93298576498958,3.2254331896798476 38.31910020350554,-2.955571037063976c83.83623127989932,-28.183883094396606 198.0851750273717,-154.030084369221 199.08078586916076,-155.64409852867644l51.06598126433914,31.500246943637762c-5.409577386928277,8.769625774145538 -129.41511742843056,146.85627742712396 -231.0275670523032,181.01613119694778c-24.82193278389599,8.344583732809383 -52.91091773805937,12.178082640769901 -79.10498961275593,2.0346504217118877c-15.357074444304459,-5.946896857197203 -28.532715560643766,-16.156819377946817 -38.967559150968384,-30.29832424159372c-16.970737553128487,-22.99907665791602 -25.951185000357953,-55.26903399719629 -28.774696789006782,-95.49782608154422z',
|
||||
'M491.2068726546696,153.8836372207983c2.67966717656293,-4.344087653601775 -5.988630526531892,6.5447012048449835 -4.103367938301176,19.82205168468778l59.40415261280532,-8.434847500372314c1.8912589260252162,13.319580925081453 -6.821144106809129,24.30583609819925 -4.234803410140444,20.11304275928262z'
|
||||
]];
|
||||
var results = [
|
||||
['M240,270l4.48298,-20.84932l-14.48298,0.84932l7.67824,-56.20204l82.32176,46.20204z M237.67824,193.79796z', 'M244.48298,249.15068l6.05168,-28.14496l12.77751,27.04076z'],
|
||||
|
@ -985,36 +991,41 @@ test('Isolated edge-cases from @iconexperience\'s boolean-test suite', function(
|
|||
['M138.31417,456.06811c1.62465,-1.18877 -18.69614,16.61617 -34.61033,15.37458l22.34488,-66.7556l-23.16516,-97.04078l209.03396,72.10619c-68.45789,0.5466 -139.96009,51.6986 -173.60335,76.31563z', 'M126.04871,404.68708l21.5947,-64.51445l-9.32924,115.89547z'],
|
||||
['M300.04122,200l-0.02301,55.81328l19.98178,24.18672l-19.98771,-9.82138l-0.01229,29.82138l-29.04124,-44.09743l-40.1367,-19.722z', 'M300.01822,255.81328l-0.00592,14.36534l-29.05353,-14.27606l-10.39571,-15.78528l29.74019,3.93662z'],
|
||||
['M320,240l-17.26682,25.90022l17.26682,34.09978l-27.9401,-18.08984l-12.0599,18.08984l-8.52877,-31.42l-35.04561,-22.69031z', 'M302.73318,265.90022l-10.67329,16.00993l-20.58867,-13.33015l-5.23726,-19.29408l29.80597,3.39596z'],
|
||||
['M157.63421,284.83942l-7.63421,44.55788l-40.73067,-80.07813l47.87749,-25.20588l4.59855,59.82352c-2.48454,0.19098 -3.64723,0.63304 -4.11116,0.90261z', 'M157.63421,284.83942c-0.00547,0.00318 -0.01083,0.00633 -0.01611,0.00945c0.0062,-0.0081 0.01246,-0.01645 0.01878,-0.02506z M157.61811,284.84887c-0.25231,0.3297 -0.39376,0.23354 0,0z'],
|
||||
['M249.53401,269.57063c-5.12674,1.32393 -6.49012,2.86652 -6.50509,2.88317c-0.17123,0.40034 -0.45801,1.48334 -0.35964,3.78705l-45.48004,-42.50042z M243.02893,272.45376c0.00005,-0.00006 0.00012,-0.00014 0.00019,-0.00023l-0.00007,-0.00006l0,0c-0.00004,0.0001 -0.00008,0.00019 -0.00012,0.00029z', 'M243.02891,272.4538c-0.00017,0.00019 -0.00017,0.00018 0.00001,-0.00003c0,0.00001 -0.00001,0.00002 -0.00001,0.00003z M243.02905,272.45347c0.12387,-0.28946 0.18715,-0.22146 0.00007,0.00006z'],
|
||||
['M157.63421,284.83942l-7.63421,44.55788l-40.73067,-80.07813l47.87749,-25.20588l4.59855,59.82352c-2.48454,0.19098 -3.64723,0.63304 -4.11116,0.90261z', 'M157.63689,284.82381l-0.00267,0.01561c-0.00547,0.00318 -0.01083,0.00633 -0.01611,0.00945c0.0062,-0.0081 0.01246,-0.01645 0.01878,-0.02506z M157.61811,284.84887c-0.25231,0.3297 -0.39376,0.23354 0,0z'],
|
||||
['M249.53401,269.57063c-5.12674,1.32393 -6.49012,2.86652 -6.50509,2.88317c-0.17123,0.40034 -0.45801,1.48334 -0.35964,3.78705l-45.48004,-42.50042z M243.02893,272.45376c0.00005,-0.00006 0.00012,-0.00014 0.00019,-0.00023l-0.00007,-0.00006c-0.00004,0.0001 -0.00008,0.00019 -0.00012,0.00029z', 'M243.02891,272.4538c-0.00017,0.00019 -0.00017,0.00018 0.00001,-0.00003c0,0.00001 -0.00001,0.00002 -0.00001,0.00003z M243.02905,272.45347c0.12387,-0.28946 0.18715,-0.22146 0.00007,0.00006z'],
|
||||
['M326.35621,259.51658c1.15567,-2.02805 1.46269,-3.25061 1.52678,-3.82669l-7.88299,-5.68989l64.9541,-12.98727l-34.9541,62.98727z', 'M327.88299,255.68989c0.00623,-0.05602 0.01017,-0.10593 0.01237,-0.14987c0.01299,0.05713 0.03113,0.12366 0.05593,0.19917z M327.89536,255.54001c-0.0732,-0.32201 0.01728,-0.34576 0,0z'],
|
||||
['M231.45711,304.56979c6.9652,-10.69831 3.685,-25.31974 -0.83742,-39.30438c2.0145,6.22942 -5.98952,-12.01465 -1.16807,-25.36373l37.6026,13.58137l20.65457,-6.67936z', ''],
|
||||
['M534.41418,349.41355c0.99527,-5.06433 -2.16222,25.36794 -15.58857,34.81815l-30.9435,-43.96286l-12.34178,-2.42547l62.78203,-185.64163l38.32358,46.16604c-12.47171,10.35308 -32.36184,100.8236 -42.23175,151.04577z', 'M534.41418,349.41355l-5.01164,-0.98491c-0.93901,-2.14075 5.01164,0.98491 5.01164,0.98491z'],
|
||||
['M534.41418,349.41355c0.99527,-5.06433 -2.16222,25.36794 -15.58857,34.81815l-30.9435,-43.96286l-12.34178,-2.42547l62.78203,-185.64163l38.32358,46.16604c-12.47171,10.35308 -32.36184,100.8236 -42.23175,151.04577z', 'M529.40254,348.42864c-0.93901,-2.14075 5.01164,0.98491 5.01164,0.98491z'],
|
||||
['M100.10301,299.83601l92.88175,81.2024l2.017,-35.39586l286.25085,96.14134l-32.50522,50.43224c-122.96966,-79.25796 -221.91462,-84.66238 -257.15913,-86.67076c1.76118,0.10036 -21.43397,0.82725 -32.77944,-9.14494z', ''],
|
||||
['M219.28387,483.73556l-19.28387,16.26444l1.41,-43.11652l-35.08866,1.12954l38.29075,-137.5648l39.73416,44.95772c-18.08687,15.98539 -18.94914,62.93097 -18.05598,90.67661c-0.2833,-8.80044 3.02337,15.67671 -7.00641,27.65301z', ''],
|
||||
['M134.30251,172.00811c69.89455,-1.62545 89.33749,-12.29848 91.81689,-13.93979c-0.39444,0.32626 -1.16469,1.04523 -2.11233,2.26401c0.67085,-0.74847 1.44456,-1.56236 2.30914,-2.40044c-0.04649,0.03433 -0.11164,0.08005 -0.19681,0.13643c0.13147,-0.10874 0.22118,-0.17386 0.26181,-0.19932c3.45306,-3.33445 8.33582,-7.03437 13.89644,-8.51327l7.76544,29.19775l-24.74271,-17.26083c-3.03845,4.3555 -2.81641,3.24058 -0.39992,0.32276l-87.20297,70.37648z', 'M224.00707,160.33233c-0.22634,0.29111 -0.46281,0.61073 -0.70669,0.96032l-0.39992,0.32276c0.32907,-0.39735 0.69884,-0.82812 1.10661,-1.28308z M226.38122,157.869c0.04659,-0.0292 0.02861,-0.00624 -0.065,0.06289c0.02161,-0.02095 0.04328,-0.04191 0.065,-0.06289z'],
|
||||
['M517.50472,202.91542l28.24931,10.08472c0.00241,0.00682 0.00483,0.01365 0.00724,0.02047l-0.00293,-0.01893c0,0 0,0 0,0c0,0 0,0 0,0l-4.59628,-29.64581c-5.58903,0.86652 -0.50164,15.25023 4.58932,29.63676c-0.44214,-0.57333 -21.80103,-28.13268 -28.24666,-10.07721z M545.75834,213.00168l12.08482,-27.45828c-8.32546,-3.66417 -12.08387,27.45042 -12.08482,27.45828c0,0 0,0 0,0z M550.35462,242.64749c5.58313,-0.86561 0.49657,-15.24328 -4.59335,-29.62688z', 'M545.75403,213.00014l0.00431,0.00154l0,0c-0.00007,-0.00009 -0.00241,-0.00314 -0.00697,-0.00905c0.00089,0.0025 0.00177,0.00501 0.00266,0.00751z'],
|
||||
['M290.12533,287.90652l22.75403,-2.60738l27.32709,-33.31167l30.67517,40.04265l-27.52018,-1.40525l1.72814,21.16356l-45.08133,-10.79944l9.90334,-12.07215z', 'M312.87936,285.29914l29.76865,-3.41118l0.71343,8.73692l-33.44985,-1.70803z'],
|
||||
['M371.53494,257.2226c-5.3407,-1.86741 -9.84549,-0.99074 -11.34052,-0.17407c0,0 0,0 0,0l-0.02947,-0.01324c0.0301,-0.00458 0.04264,0.00337 0.03269,0.01116c0.51449,-0.33235 62.44572,-40.28995 70.21684,-21.8115z M360.16495,257.03529c-0.16487,0.02506 -0.85657,0.42566 -1.2654,3.2836l-58.89955,-30.31889z', 'M360.19442,257.04853c0,0 0.00108,-0.0007 0.00322,-0.00208c-0.00089,0.0007 -0.00197,0.0014 -0.00322,0.00208z'],
|
||||
['M371.53494,257.2226c-5.3407,-1.86741 -9.84549,-0.99074 -11.34052,-0.17407l-0.02947,-0.01324c0.0301,-0.00458 0.04264,0.00337 0.03269,0.01116c0.51449,-0.33235 62.44572,-40.28995 70.21684,-21.8115z M360.16495,257.03529c-0.16487,0.02506 -0.85657,0.42566 -1.2654,3.2836l-58.89955,-30.31889z', 'M360.19442,257.04853c0,0 0.00108,-0.0007 0.00322,-0.00208c-0.00089,0.0007 -0.00197,0.0014 -0.00322,0.00208z'],
|
||||
['M409.24903,253.44031c-4.3563,1.32265 -5.54585,2.71876 -5.62356,2.81333l-0.01222,-0.01004c-0.1837,0.27203 -0.74035,1.48841 -0.57864,4.75787l-45.76718,-42.83894z', 'M403.62547,256.25365l-0.01222,-0.01004c0.06335,-0.09382 0.08235,-0.07531 0.01222,0.01004z'],
|
||||
['M292.94,321.04496l3.31075,-9.23873l-24.81246,-15.67426l0,0l0,0l0,0l0,0l48.44426,-22.36542l-13.5895,23.84665l25.09113,1.06631l18.61582,47.08061l-52.31238,-33.04622z', 'M296.25075,311.80623l5.16049,-14.40049l4.88182,0.20746l-8.60544,15.1007z M271.43829,296.13197l0,0l0,0z'],
|
||||
['M349.2989,302.36012l-42.41417,8.48166l1.38218,-3.27015l-2.93573,-15.78682l-10.2988,-2.47711l9.58086,-1.38362l-7.18085,-38.61489l32.81153,6.26643l-16.1911,38.30696z', 'M304.61324,287.92408l12.73541,-1.83919l-3.29583,7.79769l-8.72164,-2.09777z M308.40197,308.29791l-1.51724,2.54387l1.38218,-3.27015z'],
|
||||
['M150,290l30,-30l50,10l-24,16l14,14l-50,10l21.17647,-14.11765z', 'M191.17647,295.88235l14.82353,-9.88235l14,14z'],
|
||||
['M292.94,321.04496l3.31075,-9.23873l-24.81246,-15.67426l0,0l0,0l0,0l0,0l48.44426,-22.36542l-13.5895,23.84665l25.09113,1.06631l18.61582,47.08061l-52.31238,-33.04622z', 'M296.25075,311.80623l5.16049,-14.40049l4.88182,0.20746l-8.60544,15.1007z'],
|
||||
['M349.2989,302.36012l-42.41417,8.48166l1.38218,-3.27015l0,0l-2.93573,-15.78682l-10.2988,-2.47711l9.58086,-1.38362l-7.18085,-38.61489l32.81153,6.26643l-16.1911,38.30696z', 'M306.88473,310.84178l1.38218,-3.27015l0.13506,0.72628z M304.61324,287.92408l12.73541,-1.83919l-3.29583,7.79769l-8.72164,-2.09777z'],
|
||||
['M150,290l30,-30l50,10l-24,16l14,14l-50,10l21.17647,-14.11765z', 'M206,286l14,14l-28.82353,-4.11765z'],
|
||||
['M324.40827,86.1091l0.45123,-0.29442l-16.06828,-25.33943l22.46895,-3.97479l18.72801,12.91832c4.53222,6.94617 -10.24683,11.75354 -25.05014,16.51976l15.98481,25.2078l-22.46194,3.97305l6.36357,-29.14428c-0.13874,0.04467 -0.27748,0.08933 -0.4162,0.134z M324.40827,86.1091l-24.66974,16.09646c-4.37001,-6.69756 10.04945,-11.38915 24.66974,-16.09646z', 'M324.8595,85.81469l0,0l0,0z M324.93803,85.93854c-0.03785,0.01219 -0.07571,0.02438 -0.11356,0.03656l0.03503,-0.16042z'],
|
||||
['M388.92139,223.32159c120.27613,-2.24369 208.69681,19.62691 208.69681,19.62691l0.0116,0.00003l21.89025,-21.07283c0,0 8.54573,10.72909 8.51542,21.16115c-0.03104,10.68629 -208.75655,121.23392 -208.75655,121.23392z', 'M576.29425,263.48737l-8.25852,-20.6248l29.59407,0.08596z'],
|
||||
['M388.92139,223.32159c120.27613,-2.24369 208.69681,19.62691 208.69681,19.62691l0.0116,0.00003l0,0l21.89025,-21.07283c0,0 8.54573,10.72909 8.51542,21.16115c-0.03104,10.68629 -208.75655,121.23392 -208.75655,121.23392z', 'M597.62979,242.94854l-21.33555,20.53884l-8.25852,-20.6248z'],
|
||||
['M272.11155,196.81853l-22.11155,-66.81853l32.64261,64.05832c-6.17669,-1.04412 -8.29,-0.01335 -8.40866,0.04617l-0.00118,-0.00313c-0.09777,0.03858 -0.90866,0.4932 -2.12123,2.71717z', ''],
|
||||
['M386.40934,270.73027c77.4169,15.77719 129.39044,24.64733 142.22581,18.90659l5.47489,12.24096l40.60627,23.71608l-21.58416,18.81428z', 'M522.90574,295.33395c2.3982,-4.10615 5.41392,-5.55598 5.72941,-5.69709l5.47489,12.24096z'],
|
||||
['M386.40934,270.73027c77.4169,15.77719 129.39044,24.64733 142.22581,18.90659l5.47489,12.24096l0,0l40.60627,23.71608l-21.58416,18.81428z', 'M528.63515,289.63686l5.47489,12.24096l-11.2043,-6.54387c2.3982,-4.10616 5.41393,-5.55599 5.72941,-5.69709z'],
|
||||
['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.10612l0,0l-37.73535,-87.53938l36.05709,27.56285l0.78705,28.12706z', 'M556.26835,467.21638l-3.83913,-29.98827l2.94792,-1.86119l0.89121,31.84946z'],
|
||||
['M250,150l-15.25375,32.05024l29.10275,-7.1942z M225.84314,153.10482l-45.84314,36.89518l63.48255,20.45333z', 'M205.60228,189.25463l0,0.2l0.01028,-0.20254z'],
|
||||
['M598.5487,408.11025l-42.28034,59.10612l0,0l-37.73535,-87.53938l36.05709,27.56285l0.78705,28.12706z', 'M556.26835,467.21638l-3.83913,-29.98828l2.94792,-1.86119z'],
|
||||
['M570,290l5.8176,33.58557l-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', 'M538.5492,304.48516l11.83801,-5.45218l9.61279,0.96702l15.8176,23.58557z'],
|
||||
['', '']
|
||||
['', ''],
|
||||
['M419.20345,384.34607c5.84471,3.31306 8.73763,3.6008 9.66385,3.54578c0.42499,-0.23215 3.1344,-1.90017 6.91252,-9.02761c31.69382,-59.79056 16.74714,-243.86183 15.04159,-262.65257c-3.42808,-8.00965 -2.79156,-12.73288 -0.15048,-1.551l29.19538,-6.89574l-2.9917,-29.85552c34.20913,-3.42795 37.91991,47.22024 32.18962,22.95919c0.38462,1.62842 24.31406,221.98511 -20.27182,306.0966c-7.77973,14.6765 -19.84373,29.87172 -38.60351,37.019c-20.69209,7.88347 -41.8301,3.18373 -60.57335,-7.44083z', 'M450.8214,116.21167c-0.08956,-0.98671 -0.14261,-1.51768 -0.15048,-1.551l29.19538,-6.89574l2.99069,29.84549c-18.44587,1.84838 -28.02391,-12.02551 -32.0356,-21.39876z'],
|
||||
['M224.2508,238.43767c2.45124,34.92471 9.86647,54.1339 17.20117,64.07402c4.07985,5.52909 8.23969,8.37799 12.35502,9.97162c7.6805,2.97421 19.93299,3.22543 38.3191,-2.95557c81.13187,-27.27474 190.74601,-146.01269 198.63572,-155.10754c0.92148,-1.70426 1.39237,-2.07227 0.44507,-0.53656l25.35355,15.63944l29.94723,-4.25223c1.89126,13.31958 -6.82114,24.30584 -4.2348,20.11304c-5.40958,8.76963 -129.41512,146.85628 -231.02757,181.01613c-24.82193,8.34458 -52.91092,12.17808 -79.10499,2.03465c-15.35707,-5.9469 -28.53272,-16.15682 -38.96756,-30.29832c-16.97074,-22.99908 -25.95119,-55.26903 -28.7747,-95.49783z', 'M490.76181,154.42019c0.26299,-0.30316 0.41295,-0.48449 0.44507,-0.53656l25.35355,15.63944l-29.45692,4.18261c-1.21879,-8.58358 1.97318,-16.16889 3.6583,-19.28549z']
|
||||
];
|
||||
function createPath(data) {
|
||||
return typeof data === 'string' ? PathItem.create(data) : new Path({ segments: data, closed: true });
|
||||
}
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var entry = paths[i],
|
||||
result = results[i],
|
||||
path1 = new Path({ segments: entry[0], closed: true }),
|
||||
path2 = new Path({ segments: entry[1], closed: true });
|
||||
path1 = createPath(entry[0]),
|
||||
path2 = createPath(entry[1]);
|
||||
compareBoolean(path1.unite(path2), result[0], 'path1.unite(path2); // Test ' + (i + 1));
|
||||
compareBoolean(path1.intersect(path2), result[1], 'path1.intersect(path2); // Test ' + (i + 1));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue