diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-05 16:30:34 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-08-05 16:30:34 +0300 |
commit | f38a940d722064e4b3fb2df6a6c0bcc025383ca0 (patch) | |
tree | f3df6097a60b04ff324cf9105f9cb1a4dbd825c9 /src/ui/color.c | |
parent | 2b1de0641335ab1a88aeafcc8911056f155e94c9 (diff) |
Color palette theming
Diffstat (limited to 'src/ui/color.c')
-rw-r--r-- | src/ui/color.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/ui/color.c b/src/ui/color.c index 0402d0fb..a2ff6e27 100644 --- a/src/ui/color.c +++ b/src/ui/color.c | |||
@@ -100,9 +100,12 @@ static float hueToRgb_(float p, float q, float t) { | |||
100 | return p; | 100 | return p; |
101 | } | 101 | } |
102 | 102 | ||
103 | iColor fromHsl_Color(iHSLColor hsl) { | 103 | iColor rgb_HSLColor(iHSLColor hsl) { |
104 | float r, g, b; | 104 | float r, g, b; |
105 | hsl.hue /= 360.0f; | 105 | hsl.hue /= 360.0f; |
106 | hsl.hue = iWrapf(hsl.hue, 0, 1); | ||
107 | hsl.sat = iClamp(hsl.sat, 0.0f, 1.0f); | ||
108 | hsl.lum = iClamp(hsl.lum, 0.0f, 1.0f); | ||
106 | if (hsl.sat < 0.00001f) { | 109 | if (hsl.sat < 0.00001f) { |
107 | r = g = b = hsl.lum; | 110 | r = g = b = hsl.lum; |
108 | } | 111 | } |
@@ -137,7 +140,23 @@ const char *escape_Color(int color) { | |||
137 | if (color >= 0 && color < (int) iElemCount(esc)) { | 140 | if (color >= 0 && color < (int) iElemCount(esc)) { |
138 | return esc[color]; | 141 | return esc[color]; |
139 | } | 142 | } |
140 | return white_ColorEscape; | 143 | return format_CStr("\r%c", color + '0'); |
144 | } | ||
145 | |||
146 | iHSLColor setSat_HSLColor(iHSLColor d, float sat) { | ||
147 | d.sat = iClamp(sat, 0, 1); | ||
148 | return d; | ||
149 | } | ||
150 | |||
151 | iHSLColor setLum_HSLColor(iHSLColor d, float lum) { | ||
152 | d.lum = iClamp(lum, 0, 1); | ||
153 | return d; | ||
154 | } | ||
155 | |||
156 | iHSLColor addSatLum_HSLColor(iHSLColor d, float sat, float lum) { | ||
157 | d.sat = iClamp(d.sat + sat, 0, 1); | ||
158 | d.lum = iClamp(d.lum + lum, 0, 1); | ||
159 | return d; | ||
141 | } | 160 | } |
142 | 161 | ||
143 | iColor ansi_Color(iRangecc escapeSequence, int fallback) { | 162 | iColor ansi_Color(iRangecc escapeSequence, int fallback) { |