Fix gradient origin when the kFromCenter is not used (regression introduced in 250d40c0f3)

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.
This commit is contained in:
David Capello 2019-03-22 18:22:30 -03:00
parent 3c35887abf
commit 54f95dda77

View File

@ -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 {