Add path rendering and svg line output.
This commit is contained in:
parent
73051a5f27
commit
6274c41a80
15 changed files with 281 additions and 79 deletions
|
@ -1,5 +1,6 @@
|
|||
#include "SvgShapeElements.h"
|
||||
|
||||
#include "PointParser.h"
|
||||
#include <sstream>
|
||||
|
||||
SvgCircle::SvgCircle(Type type)
|
||||
|
@ -174,6 +175,45 @@ void SvgPolyline::setPoints(const std::vector<Point>& locs)
|
|||
addAttribute(std::move(points));
|
||||
}
|
||||
|
||||
void SvgPolyline::setPoints(const Point& startPoint, const std::vector<Point>& locs)
|
||||
{
|
||||
auto points = std::make_unique<XmlAttribute>("points");
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << startPoint.getX() << "," << startPoint.getY() << " ";
|
||||
|
||||
for (const auto& loc : locs)
|
||||
{
|
||||
sstr << loc.getX() << "," << loc.getY() << " ";
|
||||
}
|
||||
points->setValue(sstr.str());
|
||||
addAttribute(std::move(points));
|
||||
}
|
||||
|
||||
SvgLine::SvgLine(const Point& startPoint, const Point& endPoint, std::size_t precision)
|
||||
: SvgShapeElement("line", precision)
|
||||
{
|
||||
auto fill = std::make_unique<XmlAttribute>("fill");
|
||||
fill->setValue("none");
|
||||
addAttribute(std::move(fill));
|
||||
|
||||
auto x1 = std::make_unique<XmlAttribute>("x1");
|
||||
x1->setValue(PointParser::toString(startPoint.getX(), mPrecision));
|
||||
addAttribute(std::move(x1));
|
||||
|
||||
auto y1 = std::make_unique<XmlAttribute>("y1");
|
||||
y1->setValue(PointParser::toString(startPoint.getY(), mPrecision));
|
||||
addAttribute(std::move(y1));
|
||||
|
||||
auto x2 = std::make_unique<XmlAttribute>("x2");
|
||||
x2->setValue(PointParser::toString(endPoint.getX(), mPrecision));
|
||||
addAttribute(std::move(x2));
|
||||
|
||||
auto y2 = std::make_unique<XmlAttribute>("y2");
|
||||
y2->setValue(PointParser::toString(endPoint.getY(), mPrecision));
|
||||
addAttribute(std::move(y2));
|
||||
}
|
||||
|
||||
|
||||
SvgPath::SvgPath()
|
||||
: SvgShapeElement("path")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue