Hacker News new | ask | show | jobs
by eyegor 1855 days ago
Svg is typically a lot more complicated than coordinate points... https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Pa...
2 comments

If you can use an editor like Inkscape to flatten the image (by recursively ungrouping until every path is under the top-level <svg> tag), you should have a bunch of paths that share a coordinate space. There are pathological cases like images that use CSS for positioning, but for most cases this will work.

Then you can use something like svgpathtools (https://github.com/mathandy/svgpathtools) in Python to loop over the paths and get the coordinates.

In case it's useful, I have an example svg to gcode converter here: https://github.com/paulgb/penkit/blob/master/penkit/polargra...

It is for driving a polargraph-style plotter, so it includes a coordinate transform that GP does not need to do.

(In the context of this post, which is just straight lines)