From 9fff17787b195e53ff0d9ef97b8579b57fc10c85 Mon Sep 17 00:00:00 2001 From: Jaakko Keränen Date: Thu, 17 Feb 2022 14:29:12 +0200 Subject: Fixed mismatched banner and background There was an issue with loss of color precision. Saturation dropped to zero when converting to 8-bit RGB. --- src/ui/color.c | 4 ++-- src/ui/color.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src/ui') diff --git a/src/ui/color.c b/src/ui/color.c index 824342ae..9cba322d 100644 --- a/src/ui/color.c +++ b/src/ui/color.c @@ -522,8 +522,8 @@ iHSLColor setLum_HSLColor(iHSLColor d, float lum) { } iHSLColor addSatLum_HSLColor(iHSLColor d, float sat, float lum) { - d.sat = iClamp(d.sat + sat, 0, 1); - d.lum = iClamp(d.lum + lum, 0, 1); + d.sat = iClamp(d.sat + sat, minSat_HSLColor, 1); + d.lum = iClamp(d.lum + lum, minSat_HSLColor, 1); return d; } diff --git a/src/ui/color.h b/src/ui/color.h index 24f9e713..f46976d7 100644 --- a/src/ui/color.h +++ b/src/ui/color.h @@ -231,6 +231,8 @@ struct Impl_HSLColor { float hue, sat, lum, a; }; +#define minSat_HSLColor 0.013f /* Conversion to 8-bit RGB may result in saturation dropping to zero. */ + iHSLColor hsl_Color (iColor); iColor rgb_HSLColor (iHSLColor); float luma_Color (iColor); -- cgit v1.2.3