From 54f95dda77442a7c50c22d00415a0dfa58a1b686 Mon Sep 17 00:00:00 2001 From: David Capello Date: Fri, 22 Mar 2019 18:22:30 -0300 Subject: [PATCH] Fix gradient origin when the kFromCenter is not used (regression introduced in 250d40c0f3615db2eecc04d038da1ab52eeae265) When the kFromCenter is enabled, we have to use the middle-point of the two points controller as the origin of the floodfill algorithm, but when kFromCenter is not enabled, we use the first point. This is the only way to make both cases work well in such a way that the origin of the floodfill is not displaced when the mouse is moved. --- src/app/tools/intertwiners.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/tools/intertwiners.h b/src/app/tools/intertwiners.h index b38a42b4b..2d34f3c11 100644 --- a/src/app/tools/intertwiners.h +++ b/src/app/tools/intertwiners.h @@ -30,8 +30,13 @@ public: bool snapByAngle() override { return true; } void joinStroke(ToolLoop* loop, const Stroke& stroke) override { - if (!stroke.empty()) { - gfx::Point mid(0, 0); + if (stroke.empty()) + return; + + gfx::Point mid; + + if (loop->getController()->isTwoPoints() && + (int(loop->getModifiers()) & int(ToolLoopModifiers::kFromCenter))) { int n = 0; for (auto& pt : stroke) { mid.x += pt.x; @@ -40,9 +45,12 @@ public: } mid.x /= n; mid.y /= n; - - doPointshapePoint(mid.x, mid.y, loop); } + else { + mid = stroke[0]; + } + + doPointshapePoint(mid.x, mid.y, loop); } void fillStroke(ToolLoop* loop, const Stroke& stroke) override {