From 3542d24fda5442d5a641001556c13775b7b87f20 Mon Sep 17 00:00:00 2001 From: kobewi Date: Mon, 13 Feb 2023 01:18:44 +0100 Subject: [PATCH] Fix HSV Rectangle Wheel values --- scene/gui/color_picker.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index da29bc823fc..0b0698188c9 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -1197,11 +1197,11 @@ void ColorPicker::_uv_input(const Ref &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 &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; } }