stuff-from-scratch/test/publishing/TestSvgConverter.cpp

37 lines
884 B
C++
Raw Normal View History

2022-12-08 08:48:18 +00:00
#include "SvgWriter.h"
#include "SvgDocument.h"
#include "SvgConverter.h"
#include "Scene.h"
#include "CircleNode.h"
2022-12-08 13:52:37 +00:00
#include "RectangleNode.h"
2022-12-08 08:48:18 +00:00
#include "File.h"
#include "TestFramework.h"
#include "TestUtils.h"
TEST_CASE(TestSvgConverter, "[publishing]")
{
Scene scene;
2022-12-11 19:50:34 +00:00
//scene.setShowMeshOutline(true);
2022-12-08 08:48:18 +00:00
2022-12-11 19:50:34 +00:00
CircleNode circle({40, 40}, 20);
2022-12-08 13:52:37 +00:00
circle.setFillColor({255, 0, 0});
2022-12-08 08:48:18 +00:00
scene.addNode(&circle);
2022-12-08 13:52:37 +00:00
//RectangleNode rectangle({10, 10}, 20, 20);
//rectangle.setFillColor({255, 0, 0});
//scene.addNode(&rectangle);
2022-12-08 08:48:18 +00:00
SvgConverter converter;
auto svg_document = converter.convert(&scene);
2022-12-11 19:50:34 +00:00
svg_document->setViewBox(0, 0, 200, 200);
2022-12-08 08:48:18 +00:00
SvgWriter writer;
auto content = writer.toString(svg_document.get());
auto outFile = std::make_unique<File>(TestUtils::getTestOutputDir(__FILE__) / "scene.svg");
outFile->writeText(content);
}