mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-12 04:27:51 -05:00
render: brighten: use corresponding bright palette color for base 8 colors
When brightening one of the 8 base (“regular”) colors, use the corresponding bright palette color, instead of increasing the luminance. Closes #449
This commit is contained in:
parent
40686303ef
commit
2cd9fee9c4
2 changed files with 14 additions and 2 deletions
13
render.c
13
render.c
|
|
@ -252,8 +252,17 @@ color_dim(uint32_t color)
|
|||
}
|
||||
|
||||
static inline uint32_t
|
||||
color_brighten(uint32_t color)
|
||||
color_brighten(const struct terminal *term, uint32_t color)
|
||||
{
|
||||
/*
|
||||
* First try to match the color against the base 8 colors. If we
|
||||
* find a match, return the corresponding bright color.
|
||||
*/
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
if (term->colors.table[i] == color)
|
||||
return term->colors.table[i + 8];
|
||||
}
|
||||
|
||||
int hue, sat, lum;
|
||||
rgb_to_hsl(color, &hue, &sat, &lum);
|
||||
return hsl_to_rgb(hue, sat, min(100, lum * 1.3));
|
||||
|
|
@ -435,7 +444,7 @@ render_cell(struct terminal *term, pixman_image_t *pix,
|
|||
if (cell->attrs.dim)
|
||||
_fg = color_dim(_fg);
|
||||
if (term->conf->bold_in_bright && cell->attrs.bold)
|
||||
_fg = color_brighten(_fg);
|
||||
_fg = color_brighten(term, _fg);
|
||||
|
||||
if (cell->attrs.blink && term->blink.state == BLINK_OFF)
|
||||
_fg = color_dim(_fg);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue