Some simple svg output.

This commit is contained in:
James Grogan 2022-12-08 13:52:37 +00:00
parent 1fc730d413
commit b101a5f87c
11 changed files with 87 additions and 6 deletions

View file

@ -21,7 +21,7 @@ void SvgShapeElement::setFill(const Color& fill)
addAttribute(std::move(attr));
}
void SvgShapeElement::setStrokeWidth(unsigned width)
void SvgShapeElement::setStrokeWidth(double width)
{
auto attr = std::make_unique<XmlAttribute>("stroke-width");
attr->setValue(std::to_string(width));

View file

@ -10,7 +10,7 @@ public:
void setFill(const Color& fill);
void setStrokeWidth(unsigned width);
void setStrokeWidth(double width);
void setStrokeColor(const Color& stroke);

View file

@ -83,3 +83,24 @@ void SvgPolygon::setPoints(const std::vector<DiscretePoint>& locs)
addAttribute(std::move(points));
}
SvgPolyline::SvgPolyline()
: SvgShapeElement("polyline")
{
auto fill = std::make_unique<XmlAttribute>("fill");
fill->setValue("none");
addAttribute(std::move(fill));
}
void SvgPolyline::setPoints(const std::vector<DiscretePoint>& locs)
{
auto points = std::make_unique<XmlAttribute>("points");
std::stringstream sstr;
for (const auto& loc : locs)
{
sstr << loc.GetX() << "," << loc.GetY() << " ";
}
points->setValue(sstr.str());
addAttribute(std::move(points));
}

View file

@ -34,3 +34,11 @@ public:
void setPoints(const std::vector<DiscretePoint>& loc);
};
class SvgPolyline : public SvgShapeElement
{
public:
SvgPolyline();
void setPoints(const std::vector<DiscretePoint>& loc);
};