So for a school project Iam supposed to program a so called "V-Plotter", my team built it and I managed to program all calculations and so on, basicly I can make it move to a certain x/y coordinate and lift/raise the pen. I converted an Image with potrace to an .svg file and as far as I understood it, the file should contain a certain path which the plotter would follow.
My idea here would be to read the vector path and save it in multiple vectors via an Array, then simply make an loop going through those arrays and thus drawing the vectors. Or simply said: Loop variable i=0 Loop:
- pen up
- move to (x1/y1) of Array i
- pen down
- move to (x2/y2) of Array i
- increase i by 1 (this is not program code, but easy to program)
But i can not find any way to read the vector coordinates, shouldn't it be easy to get the coordinates where a vector starts (x1/y1) and where it stops (x2/y2)?
SVGs are very simple formats, you could simply open it with a notepad and see the xml code for it. The xml tag is the type of curve you need to plot, and it can have some metadata inside it. You can directly use python to read this XML if you want.
But SVGs aren't as easy as you're assuming it to be - it isn't simply a bunch of vectors (not the classical vectors anyway)
In SVG, you basically define shapes - like Line, Arc, CubicBezier, etc. You'd need to implement each of these into your program, because something that shows an SVG image is expected to understand these already.
Now, as your question asked about the packages, I'm adding packages that are useful for SVG handling in python:
svg.path - https://pypi.python.org/pypi/svg.path - is a great library to create paths and also to get the XML info and convert into usable classes like
Line
,Arc
etc. But I dont think they have support to read complete svg files.pysvg - https://pypi.python.org/pypi/pysvg/0.2.2 - is another utilitiy i used a while back which can import an svg and make classes like
PolyLine
circle
ellipse
etc.