stuff-from-scratch/test/graphics/TestD2dOffScreenRendering.cpp

38 lines
882 B
C++
Raw Normal View History

#include "TestCase.h"
#include "TestCaseRunner.h"
#include "TestUiApplication.h"
#include "TestFramework.h"
#include "TestUtils.h"
#include "DrawingSurface.h"
#include "DrawingContext.h"
#include "AbstractPainter.h"
#include "Image.h"
#include "PngWriter.h"
#include "RectangleNode.h"
#include "Scene.h"
TEST_CASE(TestD2dOffScreenRendering, "graphics")
{
auto surface = std::make_unique<DrawingSurface>();
2023-01-12 09:18:16 +00:00
surface->setSize(800, 800);
auto drawing_context = std::make_unique<DrawingContext>(surface.get());
2023-01-12 09:18:16 +00:00
auto rect = std::make_unique<RectangleNode>(Point(10, 10), 200.0, 200.0);
auto scene = surface->getScene();
2023-01-12 09:18:16 +00:00
//scene->setBackgroundColor(Color(100, 100, 0));
scene->addNode(rect.get());
drawing_context->paint();
auto image = surface->getImage();
PngWriter writer;
writer.setPath(TestUtils::getTestOutputDir(__FILE__) / "out.png");
2023-01-11 17:34:40 +00:00
writer.write(image);
};