From c76ce832dfe719dd8ef363501afd9743ff736b56 Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Thu, 7 Jun 2018 13:26:27 +0200 Subject: [PATCH] refs #24: rotate/position/scale according to bounding box --- src/algorithms/voronoi.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/algorithms/voronoi.cpp b/src/algorithms/voronoi.cpp index ca59e79..1cdda1a 100644 --- a/src/algorithms/voronoi.cpp +++ b/src/algorithms/voronoi.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include "voronoi.hpp" #include "../mollusc.hpp" @@ -81,7 +82,14 @@ QImage* Voronoi::createMosaic(const QImage& input, int maxNumOfMolluscs) // todo: better drawing with save/translate/rotate/restore if (mollusc.m_imageName.compare("NONE") != 0) - painter.drawPixmap(pos.x - pos.width / 2, pos.y - pos.height / 2, pos.width, pos.height, mollusc.m_image); + { + painter.save(); + painter.translate(pos.x, pos.y); + painter.rotate(-qRadiansToDegrees(pos.rotation)); + painter.translate(-pos.width / 2, -pos.height / 2); + painter.drawPixmap(0, 0, pos.width, pos.height, mollusc.m_image); + painter.restore(); + } } // clean up