I'm currently making a C++ version of python's svg.path
. There are multiple types of paths, like a Line
, CubicBezier
, etc. which are separate classes (with no inheritance, except for Line
and Close
which are inherited from Linear
but that can be removed if necessary). There's also a Path
class, which in python has a list of segments. But I'm not sure how to have a vector of segments in C++.
So something like this:
class Line {};
class CubicBezier {};
class Arc {};
class Path {
// Segment should be able to store any type of Segment like Line, Arc, etc.
vector<Segment> segments;
};
Currently the best thing I can think of is where I have a Segment
class that stores all the segment types and has various setters and getters for each of them, but that seems tedious and annoying, as well as inefficient.
Also, if there's a better way to do this (and there almost certainly is), please explain how to do that, and I'll try it.
If needed, I can post the python code from svg.path
.