summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorAnilforextra <anilforextra@gmail.com>2021-09-06 12:17:50 +0545
committerAnilforextra <anilforextra@gmail.com>2021-09-07 08:30:26 +0545
commita1f616dcfc9b4efa08a5e69e1b979ea7911dc1f8 (patch)
treec4e66098d479a7fe22ca4fcc89a211fdd6ec69c8 /scene/gui
parentc97afc033f720a68b3ea8dabb2956d836d13613e (diff)
Use builtin Vector2 functions for calculation of angles.
.
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 1afb0b8e9d..a963c03376 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -827,7 +827,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
real_t dist = center.distance_to(bev->get_position());
if (dist <= center.x) {
- real_t rad = Math::atan2(bev->get_position().y - center.y, bev->get_position().x - center.x);
+ real_t rad = bev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
s = CLAMP(dist / center.x, 0, 1);
} else {
@@ -844,7 +844,7 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
real_t dist = center.distance_to(bev->get_position());
if (dist >= center.x * 0.84 && dist <= center.x) {
- real_t rad = Math::atan2(bev->get_position().y - center.y, bev->get_position().x - center.x);
+ real_t rad = bev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
spinning = true;
} else {
@@ -889,12 +889,12 @@ void ColorPicker::_uv_input(const Ref<InputEvent> &p_event, Control *c) {
Vector2 center = c->get_size() / 2.0;
if (picker_type == SHAPE_VHS_CIRCLE) {
real_t dist = center.distance_to(mev->get_position());
- real_t rad = Math::atan2(mev->get_position().y - center.y, mev->get_position().x - center.x);
+ real_t rad = mev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
s = CLAMP(dist / center.x, 0, 1);
} else {
if (spinning) {
- real_t rad = Math::atan2(mev->get_position().y - center.y, mev->get_position().x - center.x);
+ real_t rad = mev->get_position().angle_to_point(center);
h = ((rad >= 0) ? rad : (Math_TAU + rad)) / Math_TAU;
} else {
real_t corner_x = (c == wheel_uv) ? center.x - Math_SQRT12 * c->get_size().width * 0.42 : 0;