CColor: Correct luminance setting within toHSL()

The function wasn't setting the luminance out reference, this corrects
that.
This commit is contained in:
Lioncash 2019-09-05 21:27:34 -04:00
parent 53c6c115fe
commit 9f0c1e8218
1 changed files with 3 additions and 1 deletions

View File

@ -91,11 +91,13 @@ void CColor::fromHSL(float h, float s, float l, float _a) {
void CColor::toHSL(float& h, float& s, float& l) const {
const float min = std::min({r(), g(), b()});
const float max = std::max({r(), g(), b()});
const float d = max - min;
l = (max + min) / 2.0f;
if (max == min) {
h = s = 0.f;
} else {
const float d = max - min;
s = l > 0.5f ? d / (2.f - max - min) : d / (max + min);
if (max == r()) {