From 7dbff3daa65a69ee1a0ac73a5e75d805c6a14bee Mon Sep 17 00:00:00 2001 From: David Capello Date: Wed, 8 Nov 2017 09:23:43 -0300 Subject: [PATCH] Add possibility to use paint bucket in any tile Anyway the floodfill algorithm needs some work to fully support tiled modes (e.g. don't stop at edges). Related to #1369 --- src/app/tools/point_shapes.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/app/tools/point_shapes.h b/src/app/tools/point_shapes.h index 3e4218906..916369e46 100644 --- a/src/app/tools/point_shapes.h +++ b/src/app/tools/point_shapes.h @@ -87,12 +87,31 @@ public: bool isFloodFill() override { return true; } void transformPoint(ToolLoop* loop, int x, int y) override { + const doc::Image* srcImage = loop->getFloodFillSrcImage(); + filters::TiledMode tiledMode = loop->getTiledMode(); + const bool xTiled = ((int(tiledMode) & int(filters::TiledMode::X_AXIS)) ? true: false); + const bool yTiled = ((int(tiledMode) & int(filters::TiledMode::Y_AXIS)) ? true: false); + const int w = srcImage->width(); + const int h = srcImage->height(); + + if (xTiled) { + if (x < 0) + x = (w - (-x % w)); + x %= w; + } + + if (yTiled) { + if (y < 0) + y = (h - (-y % h)); + y %= h; + } + doc::algorithm::floodfill( - loop->getFloodFillSrcImage(), + srcImage, (loop->useMask() ? loop->getMask(): nullptr), x, y, floodfillBounds(loop, x, y), - get_pixel(loop->getFloodFillSrcImage(), x, y), + get_pixel(srcImage, x, y), loop->getTolerance(), loop->getContiguous(), loop, (AlgoHLine)doInkHline);