Browse Source

Correctly scale saturation value to 0-1 in HSL Colour constructor

tags/2021-05-28
ed 5 years ago
parent
commit
f9f83fe3fa
1 changed files with 3 additions and 1 deletions
  1. +3
    -1
      modules/juce_graphics/colour/juce_Colour.cpp

+ 3
- 1
modules/juce_graphics/colour/juce_Colour.cpp View File

@@ -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);
}
}
};


Loading…
Cancel
Save