summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorkobewi <kobewi4e@gmail.com>2023-02-13 01:18:44 +0100
committerkobewi <kobewi4e@gmail.com>2023-02-13 01:18:44 +0100
commit3542d24fda5442d5a641001556c13775b7b87f20 (patch)
treedc541f63da0d82c26cd15450ffd2ba81a3f2e4b7 /scene/gui
parent27b2260460ab478707d884a16429add5bb3375f1 (diff)
Fix HSV Rectangle Wheel values
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index da29bc823f..0b0698188c 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -1197,11 +1197,11 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
}
if (!spinning) {
- real_t x = CLAMP(bev->get_position().x, corner_x, c->get_size().x - corner_x);
- real_t y = CLAMP(bev->get_position().y, corner_x, c->get_size().y - corner_y);
+ real_t x = CLAMP(bev->get_position().x - corner_x, 0, real_size.x);
+ real_t y = CLAMP(bev->get_position().y - corner_y, 0, real_size.y);
- s = (x - c->get_position().x - corner_x) / real_size.x;
- v = 1.0 - (y - c->get_position().y - corner_y) / real_size.y;
+ s = x / real_size.x;
+ v = 1.0 - y / real_size.y;
}
}
@@ -1250,11 +1250,11 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
real_t corner_y = (c == wheel_uv) ? center.y - Math_SQRT12 * c->get_size().height * 0.42 : 0;
Size2 real_size(c->get_size().x - corner_x * 2, c->get_size().y - corner_y * 2);
- real_t x = CLAMP(mev->get_position().x, corner_x, c->get_size().x - corner_x);
- real_t y = CLAMP(mev->get_position().y, corner_x, c->get_size().y - corner_y);
+ real_t x = CLAMP(mev->get_position().x - corner_x, 0, real_size.x);
+ real_t y = CLAMP(mev->get_position().y - corner_y, 0, real_size.y);
- s = (x - corner_x) / real_size.x;
- v = 1.0 - (y - corner_y) / real_size.y;
+ s = x / real_size.x;
+ v = 1.0 - y / real_size.y;
}
}