From 30b9c088b0a8955290b1c97983fd5624aa44d32f Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Tue, 7 Apr 2020 21:11:06 +0100 Subject: Plot style: Add half lighten/darken helper variants. --- include/netsurf/plot_style.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h index 6f2977f63..15069a52b 100644 --- a/include/netsurf/plot_style.h +++ b/include/netsurf/plot_style.h @@ -124,6 +124,11 @@ typedef struct plot_font_style { } plot_font_style_t; +/* Darken a colour by taking seven eighths of each channel's intensity */ +#define half_darken_colour(c1) \ + ((((7 * (c1 & 0xff00ff)) >> 3) & 0xff00ff) | \ + (((7 * (c1 & 0x00ff00)) >> 3) & 0x00ff00)) + /* Darken a colour by taking three quarters of each channel's intensity */ #define darken_colour(c1) \ ((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \ @@ -134,6 +139,12 @@ typedef struct plot_font_style { ((((9 * (c1 & 0xff00ff)) >> 4) & 0xff00ff) | \ (((9 * (c1 & 0x00ff00)) >> 4) & 0x00ff00)) +/* Lighten a colour by taking seven eighths of each channel's intensity + * and adding a full one eighth intensity */ +#define half_lighten_colour(c1) \ + (((((7 * (c1 & 0xff00ff)) >> 3) + 0x200020) & 0xff00ff) | \ + ((((7 * (c1 & 0x00ff00)) >> 3) + 0x002000) & 0x00ff00)) + /* Lighten a colour by taking 12/16ths of each channel's intensity * and adding a full 4/16ths intensity */ #define lighten_colour(c1) \ -- cgit v1.2.3