From 3569c46cf471bca4379879e752d85011c23ccc4d Mon Sep 17 00:00:00 2001 From: Lukas Wagner Date: Sat, 9 Jun 2018 19:41:40 +0200 Subject: [PATCH] refs #24: fixed black snails on edge --- src/algorithms/voronoi.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/algorithms/voronoi.cpp b/src/algorithms/voronoi.cpp index c69ba8a..0e9666d 100644 --- a/src/algorithms/voronoi.cpp +++ b/src/algorithms/voronoi.cpp @@ -58,6 +58,11 @@ QImage* Voronoi::createMosaic(const QImage& input, int maxNumOfMolluscs) auto box = calculateBoundingBox(site); + if (box.centerX < 0 || box.centerX >= width || box.centerY < 0 || box.centerY >= height) + { + continue; + } + positions.push_back(MolluscPosition{ (int)std::round(box.centerX), (int)std::round(box.centerY), (int)box.width, (int)box.height, box.rotation }); #ifdef VORONOI_USE_FLOODFILL @@ -73,7 +78,7 @@ QImage* Voronoi::createMosaic(const QImage& input, int maxNumOfMolluscs) result->fill(Qt::GlobalColor::white); QPainter painter(result); - for (auto i = 0; i < diagram.numsites; ++i) + for (auto i = 0; i < positions.size(); ++i) { auto pos = positions[i];