summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2022-02-17 14:29:12 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2022-02-17 14:29:12 +0200
commit9fff17787b195e53ff0d9ef97b8579b57fc10c85 (patch)
treea9f8a513bd56ca864753a49a89c5e04c57b00218
parentbbd7c82c7da273408ea965a9db368a35f8236943 (diff)
Fixed mismatched banner and background
There was an issue with loss of color precision. Saturation dropped to zero when converting to 8-bit RGB.
-rw-r--r--src/gmdocument.c6
-rw-r--r--src/ui/color.c4
-rw-r--r--src/ui/color.h2
3 files changed, 7 insertions, 5 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c
index bc0cc073..79deb861 100644
--- a/src/gmdocument.c
+++ b/src/gmdocument.c
@@ -1569,7 +1569,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *paletteSeed, const iB
1569 1569
1570 if (theme == colorfulDark_GmDocumentTheme) { 1570 if (theme == colorfulDark_GmDocumentTheme) {
1571 iHSLColor base = { hues[primIndex], 1571 iHSLColor base = { hues[primIndex],
1572 0.8f * (d->themeSeed >> 24) / 255.0f, 1572 0.8f * (d->themeSeed >> 24) / 255.0f + minSat_HSLColor,
1573 0.06f + 0.09f * ((d->themeSeed >> 5) & 0x7) / 7.0f, 1573 0.06f + 0.09f * ((d->themeSeed >> 5) & 0x7) / 7.0f,
1574 1.0f }; 1574 1.0f };
1575 iHSLColor altBase = { altHue, base.sat, base.lum, 1 }; 1575 iHSLColor altBase = { altHue, base.sat, base.lum, 1 };
@@ -1579,13 +1579,13 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *paletteSeed, const iB
1579 setHsl_Color(tmBannerBackground_ColorId, addSatLum_HSLColor(base, 0.1f, 0.04f * (isBannerLighter ? 1 : -1))); 1579 setHsl_Color(tmBannerBackground_ColorId, addSatLum_HSLColor(base, 0.1f, 0.04f * (isBannerLighter ? 1 : -1)));
1580 setHsl_Color(tmBannerTitle_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.1f, 0), 0.55f)); 1580 setHsl_Color(tmBannerTitle_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.1f, 0), 0.55f));
1581 setHsl_Color(tmBannerIcon_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.35f, 0), 0.65f)); 1581 setHsl_Color(tmBannerIcon_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.35f, 0), 0.65f));
1582 1582
1583// printf("primHue: %zu alts: %d %d isDarkBgSat: %d\n", 1583// printf("primHue: %zu alts: %d %d isDarkBgSat: %d\n",
1584// primIndex, 1584// primIndex,
1585// altHues[primIndex].index[altIndex[0]], 1585// altHues[primIndex].index[altIndex[0]],
1586// altHues[primIndex].index[altIndex[1]], 1586// altHues[primIndex].index[altIndex[1]],
1587// isDarkBgSat); 1587// isDarkBgSat);
1588 1588
1589 const float titleLum = 0.2f * ((d->themeSeed >> 17) & 0x7) / 7.0f; 1589 const float titleLum = 0.2f * ((d->themeSeed >> 17) & 0x7) / 7.0f;
1590 setHsl_Color(tmHeading1_ColorId, setLum_HSLColor(altBase, titleLum + 0.80f)); 1590 setHsl_Color(tmHeading1_ColorId, setLum_HSLColor(altBase, titleLum + 0.80f));
1591 setHsl_Color(tmHeading2_ColorId, setLum_HSLColor(altBase, titleLum + 0.70f)); 1591 setHsl_Color(tmHeading2_ColorId, setLum_HSLColor(altBase, titleLum + 0.70f));
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) {
522} 522}
523 523
524iHSLColor addSatLum_HSLColor(iHSLColor d, float sat, float lum) { 524iHSLColor addSatLum_HSLColor(iHSLColor d, float sat, float lum) {
525 d.sat = iClamp(d.sat + sat, 0, 1); 525 d.sat = iClamp(d.sat + sat, minSat_HSLColor, 1);
526 d.lum = iClamp(d.lum + lum, 0, 1); 526 d.lum = iClamp(d.lum + lum, minSat_HSLColor, 1);
527 return d; 527 return d;
528} 528}
529 529
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 {
231 float hue, sat, lum, a; 231 float hue, sat, lum, a;
232}; 232};
233 233
234#define minSat_HSLColor 0.013f /* Conversion to 8-bit RGB may result in saturation dropping to zero. */
235
234iHSLColor hsl_Color (iColor); 236iHSLColor hsl_Color (iColor);
235iColor rgb_HSLColor (iHSLColor); 237iColor rgb_HSLColor (iHSLColor);
236float luma_Color (iColor); 238float luma_Color (iColor);