diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-07 09:34:50 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-07 09:34:50 +0300 |
commit | 7d94fccf41ea9ba6da6d79a801fdff81a6ae9687 (patch) | |
tree | e4497cd99ab2916d04dc7f924f73b6b991a2c317 /src | |
parent | 7bbc20a1800fddb56a92ff970abd79f884fabab2 (diff) |
GmDocument: Handpicked set of primary and alt hues
Diffstat (limited to 'src')
-rw-r--r-- | src/gmdocument.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index d7140e51..20598321 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -604,13 +604,28 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
604 | d->siteIcon = siteIcons[(d->themeSeed >> 7) % iElemCount(siteIcons)]; | 604 | d->siteIcon = siteIcons[(d->themeSeed >> 7) % iElemCount(siteIcons)]; |
605 | /* Set up colors. */ { | 605 | /* Set up colors. */ { |
606 | static const float hues[] = { | 606 | static const float hues[] = { |
607 | 0, 60, 90, 100, 180, 210, 230, 260, 330 | 607 | 5, 25, 40, 56, 80, 120, 160, 180, 208, 231, 270, 324 |
608 | }; | ||
609 | static const struct { int index[2]; } altHues[iElemCount(hues)] = { | ||
610 | {2, 4}, /* red */ | ||
611 | {8, 3}, /* reddish orange */ | ||
612 | {7, 9}, /* yellowish orange */ | ||
613 | {5, 7}, /* yellow */ | ||
614 | {11, 2}, /* greenish yellow */ | ||
615 | {1, 3}, /* green */ | ||
616 | {2, 4}, /* bluish green */ | ||
617 | {2, 11}, /* cyan */ | ||
618 | {6, 10}, /* sky blue */ | ||
619 | {3, 11}, /* blue */ | ||
620 | {8, 9}, /* violet */ | ||
621 | {7, 8}, /* pink */ | ||
608 | }; | 622 | }; |
609 | const float saturationLevel = 1.0f; /* TODO: user setting */ | 623 | const float saturationLevel = 1.0f; /* TODO: user setting */ |
610 | const iBool isLightMode = iFalse; /* TODO: user setting */ | 624 | const iBool isLightMode = iFalse; /* TODO: user setting */ |
611 | const iBool isBannerLighter = (d->themeSeed & 0x4000) != 0; | 625 | const iBool isBannerLighter = (d->themeSeed & 0x4000) != 0; |
612 | const iBool isDarkBgSat = (d->themeSeed & 0x200000) != 0; | 626 | const size_t primIndex = (d->themeSeed & 0xff) % iElemCount(hues); |
613 | iHSLColor base = { hues[(d->themeSeed & 0xff) % iElemCount(hues)], | 627 | const iBool isDarkBgSat = (d->themeSeed & 0x200000) != 0 && (primIndex < 1 || primIndex > 4); |
628 | iHSLColor base = { hues[primIndex], | ||
614 | 0.8f * (d->themeSeed >> 24) / 255.0f, | 629 | 0.8f * (d->themeSeed >> 24) / 255.0f, |
615 | 0.06f + 0.09f * ((d->themeSeed >> 5) & 0x7) / 7.0f, | 630 | 0.06f + 0.09f * ((d->themeSeed >> 5) & 0x7) / 7.0f, |
616 | 1.0f }; | 631 | 1.0f }; |
@@ -622,12 +637,16 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
622 | setHsl_Color(tmBannerTitle_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.1f, 0), 0.55f)); | 637 | setHsl_Color(tmBannerTitle_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.1f, 0), 0.55f)); |
623 | setHsl_Color(tmBannerIcon_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.35f, 0), 0.65f)); | 638 | setHsl_Color(tmBannerIcon_ColorId, setLum_HSLColor(addSatLum_HSLColor(base, 0.35f, 0), 0.65f)); |
624 | 639 | ||
625 | const iBool altDir = (d->themeSeed & 0x4) != 0; | 640 | const int altIndex[2] = { (d->themeSeed & 0x4) != 0, |
626 | const float altHue = fixHue_(iWrapf(base.hue + (altDir ? 180 : -180), 0, 360)); | 641 | (d->themeSeed & 0x40) != 0 }; |
627 | float altHue2 = fixHue_(iWrapf(base.hue + (altDir ? -30 : 30), 0, 360)); | 642 | |
628 | if (altHue2 > 230) altHue2 = fixHue_(iWrapf(base.hue + (altDir ? 45 : -45), 0, 360)); | 643 | // printf("primHue: %zu alts: %d %d\n", |
629 | iHSLColor altBase = base; | 644 | // primIndex, |
630 | altBase.hue = altHue; | 645 | // altHues[primIndex].index[altIndex[0]], |
646 | // altHues[primIndex].index[altIndex[1]]); | ||
647 | const float altHue = hues[altHues[primIndex].index[altIndex[0]]]; | ||
648 | const float altHue2 = hues[altHues[primIndex].index[altIndex[1]]]; | ||
649 | iHSLColor altBase = { altHue, base.sat, base.lum, 1 }; | ||
631 | const float titleLum = 0.2f * ((d->themeSeed >> 17) & 0x7) / 7.0f; | 650 | const float titleLum = 0.2f * ((d->themeSeed >> 17) & 0x7) / 7.0f; |
632 | setHsl_Color(tmHeader1_ColorId, setLum_HSLColor(altBase, titleLum + 0.80f)); | 651 | setHsl_Color(tmHeader1_ColorId, setLum_HSLColor(altBase, titleLum + 0.80f)); |
633 | setHsl_Color(tmHeader2_ColorId, setLum_HSLColor(altBase, titleLum + 0.70f)); | 652 | setHsl_Color(tmHeader2_ColorId, setLum_HSLColor(altBase, titleLum + 0.70f)); |
@@ -650,6 +669,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
650 | } | 669 | } |
651 | else if (i == tmBackground_ColorId) { | 670 | else if (i == tmBackground_ColorId) { |
652 | color.sat = (color.sat + 1) / 2; | 671 | color.sat = (color.sat + 1) / 2; |
672 | color.lum += 0.06f; | ||
653 | } | 673 | } |
654 | else if (i == tmHeader3_ColorId) { | 674 | else if (i == tmHeader3_ColorId) { |
655 | color.lum *= 0.75f; | 675 | color.lum *= 0.75f; |
@@ -670,8 +690,7 @@ void setThemeSeed_GmDocument(iGmDocument *d, const iBlock *seed) { | |||
670 | } | 690 | } |
671 | else if (i == tmBannerBackground_ColorId) { | 691 | else if (i == tmBannerBackground_ColorId) { |
672 | if (isBannerLighter) { | 692 | if (isBannerLighter) { |
673 | color.sat = (color.sat + 1) / 2; | 693 | color.lum = 1.0f; |
674 | color.lum = (color.lum + 2) / 3; | ||
675 | } | 694 | } |
676 | else { | 695 | else { |
677 | color.sat *= 0.8f; | 696 | color.sat *= 0.8f; |