From 01967be53c5533205c53c660068084bba1fed19b Mon Sep 17 00:00:00 2001 From: David Capello Date: Thu, 17 Nov 2022 17:50:17 -0300 Subject: [PATCH] Don't put the color indicator in normal map outside the wheel (fix #3595) --- src/app/ui/color_wheel.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/app/ui/color_wheel.cpp b/src/app/ui/color_wheel.cpp index 6f0b0ea2b..187b9e2c9 100644 --- a/src/app/ui/color_wheel.cpp +++ b/src/app/ui/color_wheel.cpp @@ -344,9 +344,14 @@ void ColorWheel::onPaintMainArea(ui::Graphics* g, const gfx::Rect& rc) double x, y; double approximationThreshold = (246.0 / 255.0) * 2.0 - 1.0; - if (normalizedBlue > approximationThreshold) { // If blue is too high, we use red and green only as approximation - x = normalizedRed * m_wheelRadius; - y = -normalizedGreen * m_wheelRadius; + if (normalizedBlue > approximationThreshold) { + // If blue is too high, we use red and green only as approximation + double angle = std::atan2(normalizedGreen, normalizedRed); + double dist = std::sqrt(normalizedRed*normalizedRed + normalizedGreen*normalizedGreen); + dist = std::clamp(dist, 0.0, 1.0); + + x = std::cos(angle) * m_wheelRadius * dist; + y = -std::sin(angle) * m_wheelRadius * dist; } else { double normalizedDistance = std::cos(std::asin(normalizedBlue));