Skip to content

Instantly share code, notes, and snippets.

@veltman
Last active October 26, 2018 17:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save veltman/218a162265c772f86bc26c1bc91fe58b to your computer and use it in GitHub Desktop.
Save veltman/218a162265c772f86bc26c1bc91fe58b to your computer and use it in GitHub Desktop.
Triangulation morphing

Tweening between a single polygon (Texas) and multiple polygons (Hawaii) with an approach that's somewhat faster and more robust than this Voronoi jigsaw attempt.

This version uses earcut and some artisanal TopoJSON to triangulate the polygon and successively merge the triangles into the desired number of pieces. Then it uses this method to add points and rewind polygon pairs for smoother transitions.

The biggest area for improvement would probably be a smarter strategy for merging the polygons that factors in the relative areas and positions of the destination shapes like the Voronoi version does, or something that avoids the merge step altogether by only keeping certain cuts during the initial triangulation.

See also: Jigsaw morphing, Smoother polygon transitions

{"type":"MultiPolygon","coordinates":[[[[743.5872675202813,307.48241759969096],[746.2895624940131,309.5353697793862],[749.3538912939046,308.71812747376134],[754.1084086839987,308.9335629871571],[758.9184126382213,310.70067034739304],[768.2836930616327,313.72677683554866],[780.0899518446363,319.5897565007285],[802.0901043198803,333.1490943733638],[809.132406316452,340.02119814048865],[813.0315924369006,345.0309868144195],[813.2355947525655,350.5313721333737],[813.1561942009623,357.8610079629034],[813.623487160469,363.6211954122182],[817.3140962014431,363.3931853851468],[822.4273447389664,360.87275995231175],[826.271507111516,363.4738819122663],[828.0848276529155,366.36958199153196],[827.7559892922247,372.38599512903875],[829.5617346669835,376.0664474302148],[831.8919998404308,379.4920034646593],[838.6814500212622,385.57531158374377],[845.7701731535783,388.5233423946006],[848.6454580281047,390.9077760236478],[850.1961491778911,393.803085865678],[849.8551592639888,397.5695242013662],[848.215764834717,399.79575954581924],[842.4131200776642,407.07671916578965],[836.5932511929359,409.3731803521723],[828.3455488683464,417.6666013803847],[822.6982599166813,419.4099493090662],[822.5212572455539,421.01129802566993],[817.7726430169873,422.27274233666185],[813.793490440185,425.37561222121394],[799.2828810316028,429.9405338219649],[793.6678197591202,428.6506547912345],[790.4507421455969,428.620362281461],[787.5679016860088,429.6060110359972],[784.508089166545,431.60386243990615],[780.4135478520991,434.59937556179466],[778.0179386727041,437.6163022069859],[775.300611281431,438.0918307531342],[773.2609070155443,439.08723212595487],[768.4485607728259,442.5096546985915],[761.7506780406247,446.4586163667859],[759.7684023626489,447.17180771686617],[754.1089416977909,452.7998030513518],[753.1382283140233,455.09330108610266],[753.4230392010472,460.1796742409997],[751.0268756839978,462.8619193562199],[746.9222329629035,467.05077934780365],[744.8348840674855,472.9485907653748],[742.9513855591936,475.1304207776002],[737.477475203197,479.99999999999955],[736.2971641337781,479.3137197885876],[736.3270617727671,476.26820824140304],[733.4661725094245,474.0465933500868],[728.0689957828079,471.29825766953127],[721.6577800670457,467.53259925570774],[718.2870731277751,465.31044000049224],[710.1613358189707,463.2229684995573],[708.3623043545131,458.12687069326057],[706.6454933559796,457.6214289291361],[705.4925625574178,453.89540118642844],[704.3619447075655,447.9724998565921],[705.7824514060828,440.8925994908809],[708.4904092247605,420.519594200307],[708.1885230172402,416.96650451485175],[706.3430215963074,413.7505365073357],[704.6708982789849,409.3582297790076],[701.3882724673499,400.0320926054155],[700.051844473111,398.3315233417861],[698.6878338263548,395.46625018729947],[698.9602955595983,392.4048387646294],[697.3678098253613,389.5535358849829],[696.5572538658726,386.33802170383615],[695.0596251121024,382.4464323465245],[692.7089680134368,379.05421791664867],[690.6618707904813,377.52232528965897],[687.7626210677718,374.128038286834],[684.4574679699449,365.32481014316863],[685.7218231871327,361.3480072748839],[687.1746260291493,358.01839044593],[689.9654218544181,355.46490418538133],[692.6742439705904,353.5557141348563],[693.8812718273962,352.1480466076223],[694.5617700051218,349.4851648665067],[696.4022826793735,347.9309404441483],[701.9255274981351,345.8059731923245],[704.5236964861899,341.11509249303253],[705.8179890945237,339.49530463000883],[708.7064689184069,334.15683162445566],[711.6307321308686,330.7582642527159],[713.6739198072687,330.6668366384142],[715.0781216578105,324.43732909124174],[714.1097386524832,321.75760668819976],[711.8732247017604,319.67632702566607],[707.1488375931453,312.7036163878315],[705.1421030445447,306.5990076447674],[704.7480496847343,301.6823802490426],[704.6871405874415,297.1241579476946],[707.0919878827792,292.14813926653414],[708.8174526736734,290.56757133122665],[713.5911657522756,290.44855262963847],[722.2264777071068,292.2989113770009],[725.9510519865635,292.9876068650037],[727.1421738850399,294.70775639634894],[727.32090343404,296.06384628528485],[729.5421999833559,299.58711161093606],[734.6439553483397,301.5248232067729],[738.0116678917223,303.37739551553796],[740.370399639648,306.1039583054144],[743.5872675202813,307.48241759969096]]],[[[620.1397311619189,254.3564545041986],[618.7977719240698,256.9679904839122],[615.0520574776315,257.0509580771827],[611.5316625485775,256.4807926447752],[605.3428535785985,257.86396948814763],[601.0216711424965,258.3911297468485],[598.1709388978411,255.53539463911602],[599.7429632607473,253.46540700980813],[602.5236795035455,250.96986180200065],[606.1904288429187,248.48897447853005],[610.1664934713037,246.2156646411604],[613.6082451969401,244.9256950113845],[616.3643550914451,245.16088560070148],[619.7432349962821,248.89434962954783],[618.0560910070028,253.03213051239345],[620.1397311619189,254.3564545041986]]],[[[569.6639150943172,226.6714655873534],[563.2622249019471,227.0742299891931],[560.5645338550455,223.33414848277152],[559.9068004175949,220.06791078755487],[559.6374678264589,214.2011320618717],[559.1353745241868,211.2205204287834],[556.8659516538708,209.9160324620093],[551.3561736719936,207.81378615878612],[549.7000997647606,205.1846016506356],[550.7111449479709,202.24535074994583],[553.8129684241813,200.62649215367992],[559.2292097040836,199.89481392934067],[572.1331431885194,201.6053109432637],[578.0441748259898,206.74033553612117],[582.3305425518233,211.58655090118464],[583.7498297459056,213.88468666591598],[584.0695854062997,215.63106418441248],[583.2824874548476,218.02508150030917],[580.4974992405075,222.47986194707073],[574.5251627848488,225.28075166264534],[569.6639150943172,226.6714655873534]]],[[[611.890733941601,185.25265737964992],[612.9911548632855,186.5753691597729],[614.308711513751,186.79396172577117],[618.1616108358633,188.5645806151383],[618.8240039777513,190.33234862541985],[620.3641505883284,190.77596056871198],[620.786342848707,194.27473563147169],[622.642279081883,195.90972147634693],[623.8467410802396,197.6666905501129],[624.8257239888329,199.8554787981452],[626.3518722429119,202.26221891741625],[628.6703718647435,202.05912584888347],[630.1167937586763,200.32388183031526],[632.6508983971328,200.31749734692448],[638.4538364821783,199.7024339550385],[639.9190420846594,199.34110711168478],[644.1030348340487,196.22758831052033],[646.1683510572618,195.44872881503352],[650.4300833634827,195.18294512805778],[652.5968686976144,195.4920834700365],[655.3729803145568,196.37117528974886],[656.0987663680185,197.2006763669583],[657.7591726847122,196.63136986706377],[659.8925848579593,197.939622015052],[660.5800584541048,199.5498971625534],[663.8748051008705,203.03525917840398],[666.2807232796878,204.60704879056493],[668.0337996187524,206.2554596246373],[668.2271492820757,207.465741117991],[670.4482741638519,207.5834816798838],[670.9001404361652,206.82114403282776],[672.6552609648817,208.14319609323275],[674.2816234895414,211.10221768886777],[678.814466034909,211.67778862545993],[683.3300464525819,213.78359461618538],[689.8680621038834,215.83410669021714],[692.8838825331454,221.79752151654202],[692.2925206043767,227.35972682045985],[689.9286296465266,231.8208869479181],[686.6952220020912,232.78306250537025],[684.0269509726415,236.80009394025183],[680.4660117805277,236.88515050271963],[673.3802304546996,240.65082878067642],[668.6349854587379,240.61579215151096],[665.9925837036387,240.3782760937488],[663.5650982304235,240.578792016237],[657.026686830281,243.69386900036852],[650.6176121785079,247.03252832284943],[644.0040037753276,245.5568329571165],[642.3008135039763,246.09165091484192],[636.7340074398726,246.3888784988594],[633.010588972677,242.98263382410732],[632.5822618688975,241.56145027791354],[630.8289648826958,239.6954756228215],[631.9405601512351,238.7217993602021],[631.9575258075415,236.2131627242402],[630.8094739821713,227.04250633339234],[629.7241158908091,224.52613078427294],[629.7440856752289,221.6900297696061],[628.8773040356657,219.39257430606267],[626.0237184692203,217.29972274038118],[623.9265293260196,217.39407466748344],[622.0583746811508,218.27144147165018],[621.3694990933715,220.21316826527254],[619.7114844665224,220.52909383843325],[615.87497222707,218.11092251600576],[612.9980335382816,217.64498190367385],[610.1386471095434,215.87937031889714],[608.2601069411648,216.08415803699017],[606.5117331930846,213.7838037808324],[603.3291336712095,210.4873544574939],[599.5934465768364,205.760325875523],[599.3920418474916,202.70268167991208],[598.0681565491733,201.04844917210494],[599.3162895423585,194.27560922248585],[600.4651207977918,190.94990345215228],[601.8038708296251,188.77505841183165],[603.464822069751,188.5696468986216],[604.5660594010767,187.35321742701672],[604.6214822252286,186.26283653592373],[605.804135900542,185.4190115744218],[608.4582986916156,185.65934142893138],[610.7838093893333,184.58197857358982],[611.890733941601,185.25265737964992]]],[[[524.7130123402292,159.25673206943884],[526.8130519250132,159.59561866774038],[529.9078194391489,159.39385575965662],[531.5610522683248,159.83693291932923],[532.6609416468607,161.4799684740883],[534.6510889013939,161.45750689446595],[553.8461931602353,164.10212486464934],[558.8994842079131,164.28927849736647],[559.9251807668315,162.71586337874578],[560.7127276309653,160.32248617217329],[562.0057737426357,160.00384013756366],[563.7926818753558,162.29914661780413],[564.4368603634491,164.92035419110107],[567.4147562137057,165.80550245353515],[571.1378559585926,166.60455909849907],[577.7695199521394,166.30900091651392],[580.6653024399842,165.8801767264731],[583.8579993531142,164.70709910184132],[587.3878731244124,164.72843346920445],[590.6267898966687,165.55725102458155],[591.9416780485485,165.29023036249282],[593.2611506731666,166.93200852792052],[595.3643209268041,166.83480415080203],[596.3545045613116,167.49480750705288],[593.8947787317295,172.10229009035902],[589.8919915089455,176.08533838532276],[584.9456950429609,178.88840016739277],[580.0169526152804,181.00969275435955],[574.9468790959415,182.15033597894035],[569.8036364514367,181.7022000974407],[564.6718757439077,180.71670361673887],[554.4263352844982,178.1549138935602],[548.1481233049967,176.0516744814695],[539.2036440529067,176.87677598955906],[533.0210330337117,177.28126442946223],[528.3770724380392,178.0211891945687],[524.6332111432266,177.83754518377964],[521.7234989489539,178.02190616077496],[519.1390450923539,177.02237353182454],[517.621360371995,174.96745110508664],[517.551015948913,172.3640033184547],[518.5571196495862,170.1634618652547],[519.9971918556214,168.45760149045236],[522.3585261039386,167.53061120459824],[524.4695468015411,165.03443827866113],[525.0369599972918,162.31363109952144],[523.3809323819048,160.2302840517168],[524.7130123402292,159.25673206943884]]],[[[439.3476058510271,107.5878433988778],[440.19098540231585,110.01777933819221],[441.6142577093245,110.76838085793679],[442.3639539875006,113.19811082544038],[444.69106077801575,113.39818859688557],[446.95982645174615,116.48351756239481],[446.99414642553546,119.65592562433358],[445.27355427850193,120.4902837932209],[446.2987708355376,126.65741812608167],[449.1507667872309,127.6965609501417],[451.4173982723584,131.06851876889095],[453.41637922998655,131.73196460186136],[453.6940511884438,132.76022146069636],[455.0268116562123,133.2339679305437],[457.13132772462336,130.4391217618795],[455.13711653933865,129.12216311265183],[455.33289536979305,127.5342008311909],[456.7622660035818,126.8857509231043],[459.9976227275444,127.27284255739596],[461.61822705422776,126.81213877278242],[461.9940602057617,127.84185677777077],[460.0772423008637,129.79250650790345],[459.7140498902679,132.31835956169516],[459.97423967565504,134.28489798198189],[462.16096716992797,135.60449256744278],[463.87046946913074,137.2964730269432],[464.34251441867974,138.5020779873862],[463.7638249082023,140.10185430069396],[464.236304057044,141.69529707210359],[465.6614408297942,143.85602126042568],[468.5300264314306,145.7048493457055],[471.2925736475649,147.1258837902551],[472.1470929570242,147.9729706480498],[470.6206681868386,149.7427370097439],[466.14031035357,154.11679371687342],[464.71376749777636,154.5772701203432],[464.3407111132702,152.42371988801187],[463.2020694562881,151.48153880219843],[459.68719082197293,152.4003259422252],[456.83119034350733,152.75521725264707],[454.46232545087224,153.96493016880095],[452.7517208536056,155.36095040470673],[450.6648334316559,155.44486812768992],[449.7177362370475,154.9728072123371],[448.01769849738093,152.25230230563966],[441.4864446256469,149.42148290588466],[439.5060057530822,146.04848653091813],[438.5618789997779,145.2052047577954],[436.85175730875034,146.88078656583184],[438.172864799674,148.38000710055576],[432.67768601442026,148.82711745288634],[433.53349299314056,147.7089344990145],[432.49462227908947,146.86493042638767],[430.4108995435904,146.95107921786803],[429.85527748706716,142.55857601028356],[434.0300690200314,140.4255620690401],[434.5956128493302,139.20763470811607],[430.74897208590045,136.84777370346183],[429.67745982054794,139.19699873956824],[426.83907240953164,138.44043778649348],[427.6849527689425,140.59119395910193],[427.0206036666598,141.05591980636746],[422.9576793901623,137.67639008644437],[423.8996941782568,139.9256379184444],[426.0697825444775,142.17259752916016],[428.90311244033126,144.51707188583896],[428.2336813224728,146.66365347713418],[425.8633948351357,147.6833635246794],[417.905166033862,149.34053164527995],[415.44278763431134,149.61360405041023],[413.2939100693295,150.2505551448644],[410.52265461637376,148.66623607851488],[409.307593912893,143.990294850189],[407.9003689072873,140.24998545605695],[404.88125432927836,136.23144442339026],[402.4224323391571,135.01233055943612],[401.77070437001385,131.27770318586545],[400.92545825579555,129.31538566691688],[397.1475363453794,126.41320306347643],[395.56196456080613,123.98306539039822],[395.28763966185664,117.0822432549844],[394.40710443856676,115.83954391111638],[388.72238858550656,111.1859420648534],[389.5759056629797,110.72142080353706],[394.3145506915053,109.80037288778294],[399.90393806113906,109.44159137505403],[405.7766872078133,109.5497046360033],[407.4275580808476,109.10018633003028],[409.4710453555782,109.55951641039974],[410.52110961276014,107.04368766020934],[412.8943254955243,105.65060040585149],[416.68891158200773,102.58799336963239],[416.4955477260156,101.77486033373089],[418.64643448104545,97.60023590399169],[423.36746719054815,93.35853501647716],[427.53788347351,92.1632242178539],[430.1998947389669,92.81560734778759],[431.8257376521317,94.80634606685726],[433.97892818354626,96.56011431950856],[434.067993139079,98.05366040935996],[435.2085236656652,98.61434278687011],[435.29644745514344,99.82928598997387],[436.43146027093263,101.04529995148414],[435.8409989950065,103.56873656941161],[437.5504024192514,105.90243783915639],[439.3476058510271,107.5878433988778]]],[[[136.34083774324534,82.89448801717754],[134.62642001098044,83.40449195336578],[132.90959787225052,82.14581032932028],[131.4506916125006,81.64646175464031],[129.80385082210887,76.74514380474466],[130.14500207612204,73.57146214321665],[131.59809444597076,70.28672504122505],[136.72992436362588,65.06115908881202],[140.8499176595349,61.94456184724777],[146.1572277117772,58.91105132922394],[147.58743859663932,55.37274121110113],[147.45467965877356,52.79482393899616],[149.80446666834254,51.75459116210004],[152.03218112111801,51.83599080153499],[154.51679793033745,52.75659961598649],[155.63574459370858,55.19272854543442],[152.9048388312652,58.474509515848695],[151.94434371467972,61.47338560082744],[152.90503375345878,65.23809369245691],[151.19281993240298,67.64426977712628],[146.95757916228936,69.74879455425298],[144.48075843527175,70.51007085978745],[141.54772375007562,72.36648668800308],[139.83714396241632,73.88420909919478],[138.81320748223047,75.98927607222868],[136.34083774324534,82.89448801717754]]],[[[242.6301239188358,20.928456517277937],[244.524835317996,21.855376138727024],[246.6086163941788,21.761013035977157],[249.12129206432147,23.10146816821816],[250.1117660430242,25.197631494994766],[251.76251507809565,26.88421878666668],[252.6631608942832,27.058905701170715],[254.04950445149436,31.70327047207047],[255.17233874299583,32.345092794198536],[254.9367696203331,37.7407614473218],[253.70304905956502,39.4145429917744],[251.80739785296336,44.7114156766952],[249.90968751849374,45.82769180800642],[249.72427274907935,49.724662359280046],[250.2664460742688,54.83944813011158],[249.8178817833537,58.55608165339845],[248.01038403767052,58.553854051773214],[246.5378587259051,59.28185538963862],[248.02208626423464,61.53030015680088],[247.26537556838704,62.45965023516237],[245.71993136577203,62.35374358450417],[243.4812267369355,64.225426133984],[242.53627454611478,65.89838053896256],[239.22662411901285,68.31475394301197],[239.0386087280138,69.33785945171076],[237.61846349405133,69.52209458596099],[236.29666729084443,71.01072123255062],[230.4334568523121,68.9669997892297],[226.84143015964509,68.59763892718593],[224.16856566813613,68.68631465158842],[219.1841982378101,67.66846130606882],[217.29344286226942,67.48768712871652],[216.15887134867586,66.46513384670334],[215.40333526267494,67.5815648175726],[214.26936087294837,67.86109792992875],[213.60692101484594,66.74672578934496],[211.9039802911199,66.00662760499381],[210.39006798669138,64.79974545667892],[208.3090049147986,61.17722459511424],[206.79516022169557,60.8078714318267],[206.2280101316071,59.69303088661218],[204.9031059053762,59.04454692812806],[202.288768478747,58.63241937203611],[198.65762098343723,57.008601142287716],[193.92516050737657,55.80687686920237],[192.40686891096516,52.09245834452577],[191.26996373694993,51.53637191748385],[190.32084187578704,50.14401487701298],[190.59796672407452,44.8479552497879],[190.40677524552552,43.64038902698394],[191.71286750020155,43.15376365445945],[195.22776508085818,39.17612603608313],[197.07131412657003,36.7911618224075],[197.46987715866888,33.241415436488296],[198.3503185037968,32.84447979842298],[199.57713709010568,30.911782057693472],[205.9174884290591,29.24087621122908],[209.69428929240772,27.00022291789446],[212.05580804562027,24.948888383579742],[215.0853986407193,23.474541488667],[216.21799341865486,22.070327972682662],[217.92045829808038,21.41320162463444],[219.3403319945726,21.412824825597],[220.2860813534474,20.389834261116903],[221.61142627081324,20.667674773922045],[223.0320967666261,22.433048166366916],[225.7773168900162,23.080634815925805],[226.9132041728082,23.823685939339157],[228.0484313536286,21.685001963548984],[230.41453602769184,20.75443225590334],[232.8736446959423,21.129521063308403],[235.81139665471585,21.12068953329026],[237.3249895720922,22.05105270953436],[238.5567023697979,21.862789488171074],[241.1150433373256,19.999999999999545],[242.6301239188358,20.928456517277937]]]]}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<style>
path {
stroke: #666;
fill: #ccc;
}
.mesh {
fill: none;
}
.merging {
fill: lime;
}
</style>
</head>
<body>
<svg width="960" height="500"></svg>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
<script src="https://unpkg.com/earcut@2.1.1/dist/earcut.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.20/topojson.min.js"></script>
<script>
var svg = d3.select("svg"),
path = d3.geoPath();
d3.queue()
.defer(d3.json, "TX.json")
.defer(d3.json, "HI.json")
.await(ready);
function ready(err, tx, hi) {
var points = tx.coordinates[0],
vertices = points.reduce(function(arr, point){
return arr.concat(point);
}, []),
cuts = earcut(vertices),
triangles = [],
topology;
for (var i = 0, l = cuts.length; i < l; i += 3) {
// Save each triangle as segments [a, b], [b, c], [c, a]
triangles.push([
[cuts[i], cuts[i + 1]],
[cuts[i + 1], cuts[i + 2]],
[cuts[i + 2], cuts[i]]
]);
}
topology = createTopology(triangles, points);
svg.append("path")
.datum(tx)
.attr("class", "background")
.attr("d", path);
svg.append("path")
.attr("class", "mesh");
// Asynchronous for demo purposes
collapse(topology, 8, done);
function done(pieces) {
// Turn MultiPolygon into list of rings
var destinations = hi.coordinates.map(function(poly){
return poly[0];
});
// Get array of tweenable pairs of rings
var pairs = getTweenablePairs(pieces, destinations);
// Collate the pairs into before/after path strings
var pathStrings = [
pairs.map(function(d){ return join(d[0]); }).join(" "),
pairs.map(function(d){ return join(d[1]); }).join(" ")
];
// For showing borderless when rejoined
pathStrings.outer = join(points);
svg.select(".mesh")
.attr("d", pathStrings[0])
.classed("mesh", false)
.datum(pathStrings)
.each(morph);
}
}
function morph(d) {
var path = d3.select(this);
path.transition()
.delay(d.direction ? 0 : 1000)
.duration(0)
.attr("d", d[0])
.transition()
.duration(2500)
.attr("d", d[1])
.on("end", function(){
d.reverse();
// Show borderless
if (!(d.direction = !d.direction)) {
path.attr("d", d.outer);
}
path.each(morph);
});
}
// Merge polygons into neighbors one at a time until only numPieces remain
function collapse(topology, numPieces, cb) {
// Show fragment being merged for demo purposes
var merging = svg.append("path")
.attr("class", "merging");
var geometries = topology.objects.triangles.geometries,
bisector = d3.bisector(function(d) { return d.area; }).left;
if (geometries.length > numPieces) {
mergeSmallestFeature();
}
// Shuffle just for fun
function mergeSmallestFeature() {
var smallest = geometries[0],
neighborIndex = d3.shuffle(topojson.neighbors(geometries)[0])[0],
neighbor = geometries[neighborIndex],
merged = topojson.mergeArcs(topology, [smallest, neighbor]),
features;
// MultiPolygon -> Polygon
merged.area = smallest.area + neighbor.area;
merged.type = "Polygon";
merged.arcs = merged.arcs[0];
// Delete smallest and its chosen neighbor
geometries.splice(neighborIndex, 1);
geometries.shift();
// Add new merged shape in sorted order
geometries.splice(bisector(geometries, merged.area), 0, merged);
if (geometries.length > numPieces) {
// Don't bother repainting if we're still on tiny triangles
if (smallest.area < 50) {
return mergeSmallestFeature();
}
svg.select(".mesh")
.datum(topojson.mesh(topology, topology.objects.triangles))
.attr("d", path);
merging
.datum(topojson.feature(topology, smallest))
.attr("d", path);
setTimeout(mergeSmallestFeature, 50);
} else {
// Merged down to numPieces
features = topojson.feature(topology, topology.objects.triangles).features;
d3.selectAll(".background, .merging").remove();
cb(features.map(function(f){
return f.geometry.coordinates[0];
}));
}
}
}
function createTopology(triangles, points) {
var arcIndices = {},
topology = {
type: "Topology",
objects: {
triangles: {
"type": "GeometryCollection",
"geometries": []
}
},
arcs: []
};
triangles.forEach(function(triangle){
var geometry = [];
triangle.forEach(function(arc, i){
var slug = arc[0] < arc[1] ? arc.join(",") : arc[1] + "," + arc[0],
coordinates = arc.map(function(pointIndex){
return points[pointIndex];
});
if (slug in arcIndices) {
geometry.push(~arcIndices[slug]);
} else {
geometry.push(arcIndices[slug] = topology.arcs.length);
topology.arcs.push(coordinates);
}
});
topology.objects.triangles.geometries.push({
type: "Polygon",
area: Math.abs(d3.polygonArea(triangle.map(function(d){
return points[d[0]];
}))),
arcs: [
geometry
]
});
});
// Sort smallest first
topology.objects.triangles.geometries.sort(function(a, b){
return a.area - b.area;
});
return topology;
}
function getTweenablePairs(start, end) {
// Rearrange order of polygons for least movement
start = closestCentroids(start, end);
return start.map(function(a, i){
return align(a.slice(0), end[i].slice(0));
});
}
function align(a, b) {
// Matching rotation
if (d3.polygonArea(a) * d3.polygonArea(b) < 0) {
a.reverse();
}
// Smooth out by bisecting long triangulation cuts
bisectSegments(a, 25);
bisectSegments(b, 25);
// Same number of points on each ring
if (a.length < b.length) {
addPoints(a, b.length - a.length);
} else if (b.length < a.length) {
addPoints(b, a.length - b.length);
}
// Wind the first to minimize sum-of-squares distance to the second
return [wind(a, b), b];
}
function addPoints(ring, numPoints) {
var desiredLength = ring.length + numPoints,
step = d3.polygonLength(ring) / numPoints;
var i = 0,
cursor = 0,
insertAt = step / 2;
while (ring.length < desiredLength) {
var a = ring[i],
b = ring[(i + 1) % ring.length];
var segment = distanceBetween(a, b);
if (insertAt <= cursor + segment) {
ring.splice(i + 1, 0, pointBetween(a, b, (insertAt - cursor) / segment));
insertAt += step;
continue;
}
cursor += segment;
i++;
}
}
function wind(ring, vs) {
var len = ring.length,
min = Infinity,
bestOffset,
sum;
for (var offset = 0, len = ring.length; offset < len; offset++) {
var sum = d3.sum(vs.map(function(p, i){
var distance = distanceBetween(ring[(offset + i) % len], p);
return distance * distance;
}));
if (sum < min) {
min = sum;
bestOffset = offset;
}
}
return ring.slice(bestOffset).concat(ring.slice(0, bestOffset));
}
// Find ordering of first set that minimizes squared distance between centroid pairs
// Could loosely optimize instead of trying every permutation (would probably have to with 10+ pieces)
function closestCentroids(start, end) {
var min = Infinity,
best,
distances = start.map(function(p1){
return end.map(function(p2){
var distance = distanceBetween(d3.polygonCentroid(p1), d3.polygonCentroid(p2));
return distance * distance;
});
});
function permute(arr, order, sum) {
var cur,
distance,
order = order || [],
sum = sum || 0;
for (var i = 0; i < arr.length; i++) {
cur = arr.splice(i, 1);
distance = distances[cur[0]][order.length];
if (arr.length) {
permute(arr.slice(), order.concat(cur), sum + distance);
arr.splice(i, 0, cur[0]);
} else if (sum + distance < min) {
min = sum + distance;
best = order.concat(cur);
}
}
}
permute(d3.range(start.length));
return best.map(function(i){
return start[i];
});
}
function bisectSegments(ring, threshold) {
for (var i = 0; i < ring.length - 1; i++) {
while (distanceBetween(ring[i], ring[i + 1]) > threshold) {
ring.splice(i + 1, 0, pointBetween(ring[i], ring[i + 1], 0.5));
}
}
}
function distanceBetween(a, b) {
var dx = a[0] - b[0],
dy = a[1] - b[1];
return Math.sqrt(dx * dx + dy * dy);
}
function pointBetween(a, b, pct) {
return [
a[0] + (b[0] - a[0]) * pct,
a[1] + (b[1] - a[1]) * pct
];
}
function join(ring) {
return "M" + ring.join("L") + "Z";
}
</script>
{"type":"Polygon","coordinates":[[[385.50385503855034,20.032200322003163],[398.0247802478024,20.331203312033065],[411.47631476314757,20.556605566055605],[424.31684316843166,20.708407084070785],[448.72888728887284,20.713007130071244],[467.89567895678954,20.469204692046866],[485.220052200522,20.069000690006842],[485.81225812258117,42.09862098620981],[486.1224612246122,53.538935389353846],[486.79926799267986,78.48038480384801],[487.41027410274097,100.92400924009237],[488.99888998889986,100.11900119001187],[491.2925129251292,101.23681236812365],[496.1523615236152,106.54986549865495],[498.25798257982575,108.28408284082838],[501.54801548015473,108.32088320883206],[502.5444254442544,106.44406444064438],[504.35864358643585,106.5452654526545],[508.55108551085505,108.0172801728017],[509.22789227892275,104.49364493644934],[511.230112301123,106.50386503865036],[513.2887328873288,106.66486664866646],[513.0255302553026,107.63087630876306],[515.2251522515224,109.30069300693005],[515.1217512175122,110.60250602506022],[516.1087610876109,114.54014540145398],[518.5245852458524,114.9633496334963],[520.790007900079,114.94494944949447],[524.4372443724437,114.26414264142639],[526.7590675906758,116.0121601216012],[528.7330873308733,116.17776177761775],[531.0361103611035,117.13457134571344],[533.7151371513714,117.15757157571574],[535.2849528495285,115.74995749957498],[537.6255762557626,116.27896278962787],[541.0002100021,119.7611976119761],[543.9800398003979,117.81537815378151],[543.9236392363923,116.80796807968078],[545.0516505165051,115.5291552915529],[547.3358733587336,116.35256352563523],[549.7046970469705,116.21456214562143],[551.9795197951978,116.93676936769366],[553.4647346473464,115.14275142751426],[554.6867468674686,116.4261642616426],[553.7843378433784,118.61578615786155],[555.2131521315214,121.45861458614584],[556.7547675476753,121.76681766817666],[559.1611916119161,121.10441104411042],[560.0730007300072,121.66101661016607],[559.9131991319912,124.91784917849176],[559.0013900139002,125.6722567225672],[562.8930289302893,127.44787447874477],[565.3276532765328,126.16906169061689],[566.6624666246662,123.63443634436342],[567.7434774347744,123.45043450434503],[569.1534915349152,121.210212102121],[570.0559005590055,120.99400994009937],[572.3871238712386,122.34182341823416],[572.8477284772848,124.48544485444852],[573.9569395693957,124.69704697046969],[575.8933589335893,123.60683606836066],[577.4443744437444,124.24164241642414],[577.4537745377454,126.73946739467392],[578.8167881678817,127.67787677876777],[580.6404064040639,127.54447544475443],[581.7308173081731,125.70905709057088],[584.6730467304674,125.31805318053179],[584.9174491744916,123.62063620636204],[587.0136701367014,123.56543565435652],[587.8690786907869,126.05866058660584],[586.6282662826627,127.75147751477513],[587.211072110721,129.49949499494994],[588.6962869628696,130.94390943909437],[590.7455074550744,130.5621056210562],[590.5951059510594,127.38347383473833],[592.1085210852109,126.7072670726707],[594.1107411074111,123.31243312433122],[594.3081430814307,121.49081490814906],[595.9625596255962,120.3592035920359],[596.6675666756666,120.80540805408052],[597.1845718457184,122.92142921429212],[598.3595835958358,124.660246602466],[599.4875948759486,123.64363643636435],[600.8318083180832,123.78163781637814],[602.1478214782148,125.56185561855617],[603.7928379283792,125.12485124851247],[604.5354453544535,124.2692426924269],[604.911449114491,121.58741587415872],[607.8160781607817,122.0382203822038],[606.9324693246931,124.41644416444163],[608.7748877488775,125.20305203052028],[610.1755017550174,124.90864908649084],[611.4821148211481,126.93266932669324],[613.9449394493945,126.4542645426454],[616.2667626676266,128.8232882328823],[616.7837678376784,129.99169991699915],[618.1749817498176,129.550095500955],[618.879988799888,126.32546325463252],[621.4274142741426,127.08447084470842],[622.7998279982799,126.42666426664265],[623.5612356123561,123.05483054830546],[625.779657796578,122.4292242922429],[627.0768707687077,122.73742737427372],[630.5831058310582,121.41261412614124],[631.2129121291212,120.26260262602624],[634.7285472854728,122.03362033620334],[635.1327513275132,120.92500925009247],[636.7871678716788,121.37581375813755],[637.0597705977059,119.35639356393561],[639.4473944739448,119.25519255192549],[640.1712017120171,118.30298302983027],[641.5060150601505,118.21098210982107],[642.3896238962388,116.64696646966468],[644.0346403464034,117.23577235772355],[644.8994489944898,118.98378983789836],[648.1424814248142,119.25059250592504],[650.9249092490925,118.92858928589284],[654.7319473194732,116.45836458364582],[654.5157451574516,115.57515575155749],[655.5779557795577,114.3193431934319],[657.7775777757777,115.17035170351701],[661.9136191361913,117.78317783177829],[663.7090370903709,117.72337723377231],[664.9968499684996,118.57438574385742],[667.1494714947148,120.8192081920819],[669.1046910469104,122.13482134821346],[672.2443224432243,122.3832238322383],[673.6919369193693,123.6942369423694],[675.5625556255561,123.80463804638045],[677.2639726397263,124.47164471644714],[678.8619886198862,124.20484204842046],[680.0934009340092,125.7182571825718],[682.1708217082171,125.69525695256951],[682.7724277242771,124.88104881048808],[684.0414404144042,125.59405594055939],[686.6452664526646,128.280482804828],[687.8578785787859,127.52607526075259],[689.4182941829417,127.70547705477053],[689.8976989769897,126.36686366863667],[693.0561305613055,126.58766587665875],[693.5731357313573,125.31805318053179],[695.030150301503,126.38066380663804],[697.2485724857247,125.63085630856307],[698.7525875258752,126.43126431264311],[701.8358183581836,148.9070890708907],[703.2270322703228,159.16979169791696],[705.7744577445774,177.70337703377032],[707.7860778607785,192.2579225792258],[708.7166871668717,192.57072570725708],[710.8599085990859,195.28935289352893],[713.4731347313473,196.05756057560575],[713.6329363293632,196.85336853368534],[717.129771297713,200.79560795607958],[716.7443674436745,201.86741867418675],[718.5773857738577,203.7120371203712],[717.6937769377694,205.63025630256303],[718.1637816378163,206.51346513465134],[717.571575715757,208.35348353483536],[718.5021850218502,210.01410014100142],[720.0062000620005,211.210112101121],[721.5572155721557,210.97550975509756],[722.5160251602515,211.729917299173],[721.6606166061661,213.48253482534827],[723.9354393543936,214.5359453594536],[725.3078530785308,217.48457484574845],[724.9036490364904,219.93639936399364],[727.9304793047929,221.75801758017582],[727.9398793987939,222.90802908029082],[729.4344943449435,225.6450564505645],[730.7787077870778,224.53644536445367],[731.5871158711586,227.55867558675587],[730.8445084450843,228.61668616686168],[732.30152301523,229.30209302093022],[732.6117261172612,230.76030760307606],[731.4179141791417,233.06953069530698],[733.1005310053101,235.73755737557377],[732.4519245192453,238.32738327383277],[732.8467284672847,239.71659716597168],[730.9573095730957,246.93866938669387],[729.2652926529265,248.8246882468825],[729.7258972589725,250.8257082570826],[728.4568845688457,251.29491294912953],[727.8082780827808,253.45233452334526],[729.970299702997,257.66137661376615],[728.0526805268053,260.0672006720067],[728.1748817488174,262.739827398274],[730.9009090090901,265.4906549065491],[730.5719057190572,267.79987799878],[732.0947209472095,270.83590835908365],[731.1829118291182,272.84612846128465],[731.558915589156,274.5665456654567],[731.0231102311022,275.9373593735938],[729.349893498935,277.9107791077911],[726.9434694346944,278.19138191381916],[726.6614666146661,279.86119861198614],[725.0258502585025,283.85403854038543],[724.8754487544875,286.5358653586536],[725.2702527025269,287.810078100781],[727.7518775187752,289.8156981569816],[728.5508855088551,291.07611076110766],[728.0620806208062,291.9317193171932],[726.4546645466455,291.8535185351854],[721.8486184861849,292.40552405524056],[721.0026100261002,292.6217262172622],[718.4269842698427,294.0017400174002],[715.4471544715448,296.26036260362605],[711.1325113251132,298.59718597185974],[699.6549965499655,305.75025750257504],[698.3859838598385,306.9554695546956],[696.7033670336702,309.5820958209583],[695.9701597015969,310.04210042100425],[695.0489504895049,309.9868998689987],[695.0771507715076,308.9472894728948],[697.8031780317804,305.49725497254974],[698.7243872438723,304.84404844048447],[700.651406514065,303.91483914839154],[701.6384163841637,302.5578255782558],[702.3716237162371,302.0656206562066],[704.3080430804307,301.9230192301923],[705.4078540785408,301.329613296133],[705.4454544545445,299.8943989439895],[704.6182461824617,300.7638076380764],[702.5126251262511,299.8943989439895],[700.9522095220952,301.0766107661077],[697.5963759637596,302.12082120821213],[695.3779537795378,303.0546305463055],[695.039550395504,302.22202222022224],[696.3931639316393,299.03419034190347],[696.6657666576666,297.2585725857259],[696.8067680676807,295.19315193151937],[696.0923609236092,292.8287282872829],[695.340353403534,291.8029180291803],[694.3533435334352,291.67411674116744],[692.5015250152501,292.3733237332374],[691.9939199391993,291.9777197771978],[691.3171131711317,292.68152681526817],[691.4205142051421,293.4865348653487],[690.7437074370744,295.0045500455005],[690.3865038650385,296.58696586965874],[689.9822998229981,297.41037410374105],[688.3748837488374,298.07738077380776],[687.8578785787859,297.63117631176317],[687.4724747247471,296.6559665596656],[686.3350633506334,296.13616136161363],[684.3704437044371,295.66695666956673],[683.5150351503514,294.51694516945173],[682.810028100281,294.5445454454545],[682.5562255622556,296.2143621436215],[684.7558475584756,296.81696816968173],[685.7428574285743,297.52077520775214],[684.9532495324952,298.2981829818299],[684.7652476524765,298.99738997389977],[685.0754507545075,299.7885978859789],[686.1564615646157,300.54300543005434],[686.0436604366043,301.08121081210817],[685.150651506515,302.3278232782328],[684.9908499084991,303.5376353763538],[686.6734667346673,304.60024600246004],[689.6908969089691,305.01425014250145],[689.2020920209202,306.0032600326004],[688.6850868508684,305.8652586525866],[687.6322763227631,306.4586645866459],[688.3748837488374,307.15787157871586],[688.7414874148742,308.4550845508455],[689.7284972849727,308.37228372283727],[690.9035090350903,309.1358913589136],[693.6859368593687,309.99149991499917],[693.2253322533224,310.38250382503827],[691.7495174951748,309.92709927099276],[691.0727107271073,310.2261022610227],[690.8189081890819,312.11212112121126],[690.471104711047,313.0045300453005],[689.9258992589926,313.4323343233433],[689.2584925849258,313.00913009130096],[687.8672786727866,314.7111471114712],[685.2070520705206,318.639586395864],[683.4022340223403,320.17600176001764],[682.9792297922979,319.3847938479385],[681.4564145641457,319.2467924679247],[682.0862208622086,320.3324033240333],[681.8512185121851,321.36281362813634],[682.5374253742536,324.1228412284123],[682.650226502265,325.4844548445485],[682.4246242462425,326.08706087060875],[679.8771987719877,328.64008640086405],[678.8431884318843,329.3806938069381],[677.0289702897028,331.9935199351994],[674.7259472594726,334.4085440854409],[673.2219322193221,334.9513495134952],[670.7873078730786,337.1455714557146],[666.6418664186642,340.5726057260573],[665.0532505325052,341.5570155701557],[663.3894338943389,342.16882168821695],[661.641016410164,342.4816248162482],[659.8267982679827,342.57362573625744],[658.3885838858389,342.8818288182882],[653.3313333133331,345.3842538425385],[653.6321363213631,345.90865908659094],[653.6227362273623,348.1534815348154],[654.0833408334083,348.1442814428145],[659.4789947899478,344.2526425264253],[660.9172091720916,343.51203512035124],[662.2990229902298,343.2268322683227],[658.0219802198021,346.7964679646797],[655.6061560615606,348.3420834208343],[651.6769167691677,349.71289712897135],[649.4772947729477,351.86111861118616],[647.3058730587306,352.8547285472855],[644.9276492764927,354.6763467634677],[644.6174461744617,354.08294082940836],[645.839458394584,352.9789297892979],[651.1787117871179,349.50589505895067],[652.3913239132391,348.889488894889],[652.1375213752137,347.4864748647487],[651.3573135731358,347.1552715527156],[650.5959059590596,347.36687366873673],[649.1858918589185,348.3972839728398],[647.9074790747907,348.89408894088945],[645.6984569845697,350.21890218902195],[643.8936389363894,350.9457094570946],[643.1416314163141,350.30630306303067],[643.790237902379,349.8784987849879],[645.5668556685566,349.49669496694975],[645.670256702567,348.5812858128582],[644.1098410984109,349.11949119491203],[643.2920329203291,349.07809078090787],[643.2074320743206,348.2546825468255],[643.9688396883969,346.6906669066691],[643.7996379963799,346.0972609726098],[641.271012710127,346.60786607866083],[640.4908049080491,347.08627086270866],[639.5695956959569,348.47088470884717],[638.159581595816,349.3126931269313],[637.6801768017681,348.5214852148522],[636.1855618556185,347.10007100071005],[636.570965709657,345.88565885658863],[635.6685566855667,344.689646896469],[634.9729497294973,345.3704537045371],[634.1551415514155,344.28024280242806],[633.8261382613825,344.59764597645983],[634.7661476614767,346.3364633646337],[635.4993549935498,348.17188171881725],[635.3395533955338,349.20689206892075],[637.2571725717257,349.79109791097915],[635.1233512335123,351.40571405714064],[634.4371443714438,351.38271382713833],[634.5969459694597,350.4903049030491],[634.1833418334184,349.6806968069681],[632.8109281092811,350.84910849108496],[632.181121811218,349.45989459894605],[631.3163131631316,349.73589735897366],[630.1225012250122,349.62089620896217],[629.7088970889708,349.26209262092624],[629.2294922949229,347.4036740367404],[628.2236822368222,346.42386423864247],[627.1520715207153,346.44226442264426],[626.6820668206681,346.78266782667833],[625.8172581725817,346.2214622146222],[626.1932619326192,348.1074810748108],[627.8382783827838,350.1775017750178],[628.1578815788157,350.9227092270923],[628.0920809208092,352.8041280412805],[629.1354913549135,352.70752707527083],[631.6735167351674,353.8115381153812],[632.2657226572264,354.31294312943135],[632.9049290492906,355.4353543535436],[630.940309403094,356.6543665436655],[631.570115701157,357.41797417974186],[632.6041260412603,356.57616576165765],[633.750937509375,356.12996129961306],[635.2925529255292,356.53476534765355],[636.5239652396524,357.4363743637437],[636.740167401674,358.4943849438495],[634.051740517405,360.2884028840289],[633.309133091331,360.55520555205555],[627.3776737767378,364.5802458024581],[626.6256662566625,364.08804088040887],[626.0052600526005,364.3502435024351],[625.2626526265262,363.3106331063311],[625.0370503705037,361.6730167301674],[624.4730447304473,360.96000960009604],[623.5330353303532,360.8128081280813],[623.2510325103251,359.74099740997417],[622.3956239562394,359.22579225792265],[621.230012300123,357.8963789637897],[620.6190061900618,358.4851848518486],[622.0196201962019,359.7363973639737],[622.5460254602547,360.89560895608963],[622.2640226402264,361.3832138321384],[620.0550005500054,360.30220302203026],[619.4721947219473,360.94620946209466],[620.3370033700337,362.11922119221197],[621.6342163421634,363.4256342563426],[622.2922229222293,364.479044790448],[621.7094170941709,366.9124691246913],[622.6118261182612,368.5316853168532],[622.2640226402264,369.14809148091484],[620.919809198092,370.1601016010161],[619.0961909619095,372.96152961529623],[618.5133851338512,373.45373453734544],[616.6145661456615,374.2679426794269],[616.9341693416934,372.588925889259],[617.7237772377723,371.0571105711058],[617.0845708457084,370.2613026130262],[617.5827758277583,368.6466864668647],[616.9999699996999,368.039480394804],[615.7027570275702,370.3027030270303],[616.2667626676266,370.73510735107357],[616.2855628556285,372.1335213352134],[615.4771547715477,374.02414024140245],[615.0447504475044,374.2633426334264],[613.5877358773587,373.90913909139095],[613.879138791388,371.41591415914166],[613.3245332453323,370.8133081330814],[612.7699276992769,371.8253182531826],[611.4539145391454,372.81892818928196],[609.9592995929959,373.5963359633597],[608.7936879368792,373.15013150131506],[607.7502775027749,373.1547315473155],[607.3272732727328,374.0655406554066],[608.1638816388163,374.64054640546414],[606.669266692667,376.439164391644],[605.9924599245992,377.4925749257493],[606.3778637786377,377.90197901979025],[608.0134801348013,378.1963819638197],[609.6866968669685,379.82019820198207],[610.4387043870438,377.30397303973047],[612.2999229992299,376.33796337963383],[613.0989309893098,374.87974879748805],[613.70053700537,375.6985569855699],[613.5877358773587,377.4649746497466],[613.7663376633766,378.3619836198363],[612.2059220592205,380.55160551605525],[610.9651096510966,383.33463334633353],[608.1920819208192,388.11868118681195],[607.3648736487364,388.86388863888646],[606.030060300603,387.06067060670614],[604.7234472344724,386.4580645806459],[603.7928379283792,386.65586655866565],[602.2324223242233,387.48847488474894],[600.7190071900718,387.0514705147052],[597.3631736317363,387.31367313673144],[597.090570905709,387.9024790247903],[596.0001600016001,387.72767727677285],[595.7463574635747,387.25387253872543],[594.6183461834619,387.5206752067521],[595.3421534215342,388.56488564885655],[596.1035610356103,389.13069130691315],[597.0341703417034,389.22269222692233],[598.3031830318303,388.81788817888184],[599.6473964739646,388.7856878568786],[600.1738017380173,389.05709057090576],[599.9387993879939,390.3635036350364],[600.9822098220982,392.39212392123926],[601.659016590166,392.9533295332954],[605.3438534385343,394.1953419534196],[605.6164561645617,395.4833548335484],[604.6952469524695,397.2543725437255],[604.5824458244583,398.7769877698778],[603.4168341683417,401.56461564615654],[602.8904289042889,403.6070360703608],[602.7306273062729,404.9916499164992],[602.2136221362214,405.7138571385715],[600.9164091640916,410.539305393054],[600.8788087880878,411.5605156051561],[600.4558045580454,411.92391923919246],[597.9271792717927,413.20273202732034],[597.1375713757136,414.25154251542523],[596.5735657356572,414.4723447234473],[595.7651576515764,413.99393993939947],[597.1751717517175,413.09693096930977],[597.8425784257843,412.01132011320124],[598.5381853818537,411.7399173991741],[598.3407834078341,410.99010990109906],[597.4759747597475,410.5853058530586],[597.5981759817598,408.83268832688333],[596.8461684616846,409.2420924209243],[595.5113551135512,410.5761057610577],[595.8591585915858,411.17871178711795],[594.5243452434524,412.21372213722145],[593.8569385693856,411.78591785917865],[593.1989319893198,412.9313293132932],[593.3305333053331,413.52473524735257],[592.1555215552155,413.80993809938104],[591.770117701177,412.728927289273],[588.2074820748207,408.28068280682817],[587.1170711707116,407.3422734227343],[585.7916579165792,406.57866578665795],[586.0266602666027,407.65507655076556],[587.4930749307493,408.94308943089436],[587.4084740847409,409.8952989529896],[588.9782897828977,411.25691256912575],[589.7772977729776,412.84392843928447],[590.6045060450604,413.4327343273433],[589.3542935429355,414.66554665546664],[588.3766837668377,414.6563465634657],[587.3238732387324,414.2883428834289],[586.9572695726956,415.14855148551493],[588.8278882788827,415.5533555335554],[591.0839108391083,415.07955079550806],[591.779517795178,415.36475364753653],[592.3623236232361,416.3353633536336],[593.6407364073641,416.3169631696318],[595.2293522935229,416.57456574565754],[596.789767897679,416.57456574565754],[599.9293992939929,414.5045450454505],[600.5310053100532,414.8541485414855],[600.2960029600295,415.9857598575987],[599.8259982599825,416.2111621116212],[600.0234002340023,418.3455834558346],[599.5345953459534,418.9941899418995],[600.1832018320183,420.8756087560876],[599.449994499945,421.8600186001861],[598.2091820918208,422.24642246422474],[598.9423894238942,423.6448364483646],[598.5099850998511,424.1600416004161],[599.0927909279092,425.26865268652693],[599.1585915859159,426.0322603226033],[598.6321863218632,426.4968649686498],[596.3761637616376,426.8280682806829],[595.9155591555916,427.56867568675693],[596.1787617876178,429.52369523695245],[596.470164701647,430.3149031490316],[597.381973819738,431.4511145111452],[599.0551905519055,432.0721207212073],[599.6379963799639,432.6241262412625],[599.2243922439225,433.53953539535405],[597.2785727857279,431.97551975519764],[596.8273682736826,431.80991809918106],[596.4513645136451,433.14853148531495],[596.479564795648,434.68954689546905],[596.8179681796817,435.2461524615247],[598.5287852878528,435.4761547615477],[599.0645906459065,435.93155931559323],[599.7037970379704,437.33457334573353],[600.1362013620135,439.31259312593136],[601.339413394134,442.17382173821744],[601.9974199741996,445.16385163851646],[603.1442314423143,448.1400814008141],[602.7494274942749,449.32229322293233],[601.330013300133,450.0859008590087],[602.7682276822768,450.45850458504594],[602.5896258962589,451.58091580915817],[602.6084260842608,453.48073480734814],[603.8962389623896,453.6141361413615],[604.5260452604525,455.25635256352575],[605.9830598305982,455.4311543115432],[605.7292572925728,456.7651676516766],[606.80086800868,456.2223622236223],[607.3272732727328,456.7467674676748],[606.7538675386754,457.4229742297424],[606.669266692667,459.38259382593833],[607.0452704527045,459.8011980119802],[607.9758797587976,459.4699946999471],[608.6150861508615,460.19680196801977],[608.1450814508144,461.2962129621297],[609.1414914149141,463.1132311323114],[609.0568905689056,465.4822548225483],[609.3482934829349,466.70586705867066],[610.8523085230852,467.6350763507636],[612.5161251612515,467.61667616676175],[613.550135501355,467.8512785127852],[613.2211322113221,469.0012900129002],[612.1965219652195,468.91848918489194],[611.8017180171801,470.8781087810879],[612.0931209312093,472.2581225812259],[612.9485294852948,472.87452874528753],[614.3021430214301,471.79351793517947],[614.9225492254923,470.94250942509433],[615.1481514815148,468.66548665486664],[616.1069610696106,468.3940839408395],[616.5675656756566,469.62229622296235],[617.0657706577065,473.21033210332115],[614.1235412354124,473.74393743937446],[611.3881138811387,474.4937449374495],[609.470494704947,476.24636246362473],[607.5058750587505,476.95016950169514],[608.2484824848248,478.15538155381563],[607.7878778787788,480.0000000000001],[604.8080480804808,479.8297982979831],[603.5484354843547,478.07718077180783],[601.4710147101471,478.3439834398345],[600.9352093520936,476.789167891679],[598.7261872618726,476.14056140561416],[596.8743687436875,473.8773387733878],[594.890948909489,472.18452184521857],[592.4563245632455,472.65832658326593],[589.7772977729776,472.3501235012351],[589.109891098911,471.1771117711178],[587.2486724867249,471.6601166011661],[585.9984599845998,471.1357113571137],[582.4170241702416,471.9959199591997],[581.4958149581496,471.4209142091422],[579.4465944659446,472.649126491265],[576.6547665476655,471.6739167391675],[573.8441384413843,471.73371733717346],[572.7537275372754,472.4651246512466],[570.6199061990619,471.82571825718264],[567.320473204732,469.6958969589697],[566.8786687866877,467.91567915679167],[564.660246602466,468.20548205482066],[562.2444224442245,466.4482644826449],[561.3232132321323,465.2568525685258],[559.6687966879667,466.1400614006141],[556.3599635996359,464.19884198842],[552.9383293832939,465.2844528445285],[552.289722897229,464.1758417584177],[549.9866998669986,462.48762487624884],[549.1970919709197,461.09381093810947],[548.0690806908069,461.36061360613616],[546.1702617026169,459.36419364193654],[543.1058310583105,460.32560325603265],[542.8144281442815,459.52059520595213],[540.5678056780566,459.36419364193654],[539.7593975939758,458.2877828778289],[538.2741827418274,458.7753877538776],[537.1367713677137,457.83697836978376],[535.3131531315312,458.7017870178703],[534.0629406294063,457.39537395373964],[534.7491474914748,455.23335233352344],[533.1323313233131,452.85972859728605],[531.5343153431534,452.4411244112442],[530.8951089510895,448.5770857708578],[529.9174991749917,446.9992699927],[529.4192941929418,443.8482384823849],[528.1032810328103,442.9328293282934],[527.9246792467925,440.99160991609926],[526.7402674026739,438.51678516785176],[524.2116421164211,436.9251692516926],[523.7886378863789,434.9885498854989],[521.6642166421664,434.0915409154092],[522.0590205902058,432.72072720727215],[520.4234042340423,430.7933079330794],[519.1637916379163,430.5771057710578],[518.8817888178882,428.5852858528586],[519.5397953979539,428.0240802408025],[519.1919919199191,424.69364693646946],[519.690196901969,423.4516345163452],[518.9475894758948,420.20860208602096],[516.6727667276673,419.219592195922],[516.240362403624,416.2019620196203],[516.7855678556784,412.8301283012831],[516.4283642836428,411.1051110511106],[517.020570205702,409.8446984469845],[514.9995499954999,409.01669016690175],[515.5917559175591,405.98985989859904],[514.2757427574275,404.14984149841507],[511.73771737717374,402.60882608826097],[510.33710337103366,403.349433494335],[509.0774907749077,401.88201882018825],[506.95306953069525,401.6750167501676],[504.8756487564875,398.74478744787456],[503.6254362543625,398.349183491835],[503.11783117831175,396.9001690016901],[501.92401924019237,397.1853718537186],[500.7114071140711,396.0123601236013],[500.27900279002785,393.5605356053561],[499.320193201932,392.4243242432425],[499.7243972439724,391.32951329513304],[497.8443784437844,388.90068900689016],[498.0793807938079,387.6724767247673],[495.74815748157476,387.2032720327204],[494.4885448854488,383.909639096391],[493.10673106731065,383.11843118431193],[491.6873168731687,380.35380353803544],[486.67706677066764,378.35278352783536],[486.1412614126141,376.49896498964995],[484.77824778247776,376.3011630116302],[483.2836328363283,374.35074350743514],[483.48103481034804,372.87412874128745],[480.990009900099,369.1250912509126],[481.4788147881478,367.81867818678194],[480.19100191001905,365.8268582685827],[481.4694146941469,364.66304663046634],[479.3919939199392,364.08804088040887],[478.3955839558395,362.4044240442405],[478.87498874988745,360.9002090020901],[476.910369103691,359.82379823798243],[476.30876308763084,358.439184391844],[474.78594785947854,357.53297532975336],[474.43814438144375,354.00934009340097],[473.2161321613216,352.22912229122295],[472.84012840128395,350.2603026030261],[471.63691636916366,349.8186981869819],[470.5747057470574,346.83326833268336],[469.4372943729437,346.82406824068244],[468.7040870408704,342.4816248162482],[467.59487594875947,338.0057800578006],[465.13205132051314,336.3313633136332],[462.64102641026403,331.46911469114696],[459.58599585995853,330.0753007530076],[459.2381923819238,328.87928879288796],[456.7377673776737,327.1312713127132],[454.660346603466,326.39066390663913],[453.38193381933814,324.55984559845604],[452.4419244192442,322.23222232222327],[448.8886888868888,321.44101441014413],[448.02388023880235,319.7757977579776],[444.6492464924649,318.8051880518806],[445.420054200542,317.549375493755],[443.99123991239907,316.4085640856409],[442.68462684626843,316.66616666166664],[443.1264312643126,314.19594195941966],[442.5812258122581,313.3863338633387],[440.6824068240682,313.6761367613677],[440.2124021240212,311.49571495714963],[438.6613866138661,309.51309513095134],[437.38297382973826,309.33369333693344],[437.110371103711,307.6776767767678],[435.3995539955399,308.66208662086626],[433.90493904939046,308.84148841488417],[434.06474064740644,307.24987249872504],[432.80512805128046,307.2038720387204],[429.7594975949759,309.1542915429155],[429.13909139091385,308.42288422884235],[427.24967249672494,308.7816878168782],[424.53304533045326,307.5948759487595],[417.8965789657896,307.2820728207283],[416.90016900168996,306.3988639886399],[414.2963429634296,307.6730767307673],[411.70191701917014,307.3188731887319],[410.0569005690056,306.3436634366344],[408.9570895708957,304.8164481644817],[407.6880768807688,305.17525175251757],[404.7082470824708,303.4916349163492],[403.10083100831,303.8366383663837],[400.6098060980609,308.39988399884004],[399.4817948179481,307.85707857078575],[396.4361643616436,308.26188261882623],[395.07315073150727,309.209492094921],[394.1613416134161,308.6206862068621],[391.3037130371303,309.609696096961],[390.10050100501,309.2646926469265],[389.40489404894043,312.0937209372094],[387.7974779747797,313.6025360253603],[387.5342753427534,315.5483554835549],[386.42506425064244,315.67715677156775],[386.00206002060014,317.93577935779365],[384.82704827048263,318.81898818988196],[384.82704827048263,320.11160111601123],[383.7836378363783,322.8256282562826],[384.0092400924009,324.4126441264413],[383.20083200832005,326.13766137661383],[381.9412194121941,326.2342623426235],[380.71920719207185,330.3375033750338],[382.1950219502195,332.07632076320766],[378.89558895588954,334.0313403134032],[377.8145781457814,333.6357363573636],[375.55855558555584,337.38477384773853],[374.7783477834778,337.3755737557376],[372.92652926529263,339.10979109791106],[372.9641296412964,340.61400614006146],[370.69870698706984,343.0244302443025],[368.7716877168771,342.2654226542266],[366.93866938669385,342.509225092251],[366.3652636526365,341.8100181001811],[363.54523545235446,340.61400614006146],[361.67461674616743,340.4852048520486],[359.2775927759277,338.42898428984296],[356.4763647636476,335.1353513535136],[355.26375263752635,334.2705427054271],[352.2745227452274,334.0175401754018],[349.5954959549595,332.7525275252753],[347.6120761207612,331.0873108731088],[346.64386643866436,329.01729017290177],[341.1824118241182,327.4854748547486],[339.38699386993864,327.32907329073294],[337.5445754457544,326.52866528665294],[335.2133521335213,324.90024900249006],[334.320343203432,323.63523635236356],[331.98911989119887,322.51282512825134],[330.4475044750447,320.04720047200476],[330.59790597905976,318.64418644186446],[327.3078730787307,316.57416574165745],[325.70045700457,316.66616666166664],[323.60423604236036,314.9503495034951],[323.48203482034813,314.2465424654247],[319.2143921439214,311.0449104491045],[318.1521815218152,309.089890898909],[318.0863808638086,306.45406454064545],[313.70593705937057,298.4407844078441],[313.6025360253602,295.94295942959434],[312.8599285992859,292.43312433124333],[313.9597395973959,286.7888678886789],[313.12313123131224,284.1576415764158],[311.4123141231412,282.3406234062341],[311.4593145931459,281.2780127801278],[309.63569635696354,279.7047970479705],[309.7484974849748,278.42138421384215],[307.990679906799,277.0827708277083],[307.7274772747727,272.46432464324647],[306.98486984869845,269.1108911089111],[305.7534575345753,267.76767767677677],[304.36224362243615,267.2248722487225],[303.95803958039573,264.87424874248745],[303.2060320603206,263.7932379323794],[301.15681156811564,263.6460364603646],[299.27679276792765,261.0378103781038],[295.66715667156666,258.0339803398034],[294.4357443574435,258.25018250182507],[291.22091220912205,256.21236212362123],[289.48189481894815,255.5177551775518],[289.1152911529115,253.95833958339585],[283.541035410354,249.10529105291056],[282.7232272322723,246.09686096860972],[280.5424054240542,243.35523355233553],[278.3897838978389,242.31102311023113],[277.26177261772614,240.98620986209863],[276.0585605856058,240.7056070560706],[275.4287542875428,239.17839178391785],[272.93772937729375,235.19015190151904],[270.71930719307187,233.97113971139714],[270.0895008950089,231.66191661916622],[268.2094820948209,230.26810268102682],[265.69965699656996,229.84949849498497],[263.6974369743697,228.48328483284834],[260.680006800068,225.760057600576],[259.96559965599647,223.23463234632348],[258.7529875298752,222.10762107621076],[257.9915799157991,219.07619076190764],[255.69795697956974,214.4071440714407],[253.2445324453244,212.7787277872779],[251.74991749917496,213.3169331693317],[250.49970499704992,211.71151711517115],[248.81708817088165,210.3729037290373],[246.8994689946899,207.76467764677648],[246.8994689946899,206.07186071860718],[247.98987989879893,205.53365533655338],[247.22847228472278,202.84262842628428],[248.0744807448074,202.0468204682047],[267.00627006270054,203.64763647636477],[278.5213852138521,204.63204632046322],[298.22398223982236,206.14546145461455],[316.16876168761684,207.28627286272862],[333.22993229932297,208.25228252282523],[354.0511405114051,209.20449204492044],[378.05898058980586,210.0279002790028],[378.66998669986697,188.49048490484904],[379.2809928099281,167.06347063470633],[380.1364013640136,148.49768497684977],[381.2362123621236,124.38424384243841],[381.66861668616684,108.6382863828638],[382.4394243942439,82.42262422624222],[382.94702947029464,64.88264882648822],[383.2478324783247,54.65674656746563],[383.83063830638304,34.283142831428265],[384.1972419724197,19.999999999999943],[385.50385503855034,20.032200322003163]]]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment