mirror of
https://github.com/aseprite/aseprite.git
synced 2025-03-16 10:20:50 +00:00
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.
This commit is contained in:
parent
3c35887abf
commit
54f95dda77
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user