From f9f83fe3faac599cb905c33f0940775109cbfd78 Mon Sep 17 00:00:00 2001 From: ed Date: Fri, 19 Feb 2021 13:02:23 +0000 Subject: [PATCH] Correctly scale saturation value to 0-1 in HSL Colour constructor --- modules/juce_graphics/colour/juce_Colour.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/juce_graphics/colour/juce_Colour.cpp b/modules/juce_graphics/colour/juce_Colour.cpp index 007a2f3645..25c748b836 100644 --- a/modules/juce_graphics/colour/juce_Colour.cpp +++ b/modules/juce_graphics/colour/juce_Colour.cpp @@ -84,7 +84,7 @@ namespace ColourHelpers if (lightness > 0.0f) hue = getHue (col); - saturation = (float) (hi - lo) / (1.0f - std::abs ((2.0f * lightness) - 1.0f)); + saturation = ((float) (hi - lo) / 255.0f) / (1.0f - std::abs ((2.0f * lightness) - 1.0f)); } } @@ -691,6 +691,8 @@ public: testColour (red.withMultipliedSaturationHSL (0.0f), 128, 128, 128); testColour (red.withMultipliedBrightness (0.5f), 128, 0, 0); testColour (red.withMultipliedLightness (2.0f), 255, 255, 255); + testColour (red.withMultipliedLightness (1.0f), 255, 0, 0); + testColour (red.withLightness (red.getLightness()), 255, 0, 0); } } };