Home > Blockchain >  SVG Commands to an array of points in python for plotting
SVG Commands to an array of points in python for plotting

Time:12-29

I have SVG commands printed out in this style:

M 17.674207527416044,-2.0071468002689765
L 18.71594797636461,-2.1235197095441456
C 18.826423339069347,-2.1286537329883464 19.15862036824475,-2.1295142834870036 19.714241351132454,-2.0062766509553485 20.37767811352802,-1.85633105768394 21.328536750145904,-1.5307796874983068 22.48762758994496,-0.8307488372990495
A 22.5,22.5 0 0,1 22.48762758994496,0.8307488372990495
C 21.328536750145904,1.5307796874983068 20.37767811352802,1.85633105768394 19.714241351132454,2.0062766509553485 19.15862036824475,2.1295142834870036 18.826423339069347,2.1286537329883464 18.71594797636461,2.1235197095441456
L 17.674207527416044,2.0071468002689765
A 0.9375,0.9375 0 0,0 16.643970594477892,2.7827805968410724
A 16.875,16.875 0 0,1 16.44194780227596,3.798417758387414
A 0.9375,0.9375 0 0,0 17.096940414724138,4.909264553410452
L 18.10391707805257,5.200406815029517
C 18.20794771021571,5.237940686841614 18.515187064650465,5.3642719411955415 18.98135291836046

How do I convert this into an image and also be able to generate intermediate points/an array of points, so I can create a 2d plot in python?

Thanks for helping.

CodePudding user response:

You can try this python package svgpath2mplhttps://github.com/nvictus/svgpath2mpl. It can convert the SVG path to a matplotlib object.

  • Related