Initial svg support.

This commit is contained in:
James Grogan 2022-12-07 20:58:45 +00:00
parent 101bfb4207
commit 65ac927929
22 changed files with 284 additions and 30 deletions

View file

@ -1,6 +1,7 @@
set(WEB_UNIT_TEST_FILES
web/TestMarkdownParser.cpp
web/TestXmlParser.cpp
web/TestSvgWriter.cpp
PARENT_SCOPE
)

View file

@ -0,0 +1,33 @@
#include "SvgWriter.h"
#include "SvgDocument.h"
#include "SvgShapeElements.h"
#include "File.h"
#include "TestFramework.h"
#include "TestUtils.h"
TEST_CASE(TestSvgWriter, "web")
{
auto document = std::make_unique<SvgDocument>();
document->setViewBox(0, 0, 100, 100);
auto circle = std::make_unique<SvgCircle>();
circle->setRadius(20);
circle->setLocation({10, 30});
circle->setFill({255, 0, 0});
document->getRoot()->addChild(std::move(circle));
auto rectangle = std::make_unique<SvgRectangle>();
rectangle->setLocation({50, 70});
rectangle->setWidth(5);
rectangle->setHeight(10);
rectangle->setFill({0, 0, 255});
document->getRoot()->addChild(std::move(rectangle));
SvgWriter writer;
auto content = writer.toString(document.get());
auto outFile = std::make_unique<File>(TestUtils::getTestOutputDir(__FILE__) / "test_out.svg");
outFile->writeText(content);
}