From 3626a5654e858ca6915327628e58a09e938392f4 Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Sat, 23 May 2020 21:31:05 +0100 Subject: Plot style: Helper macro to get nearest of black and white. --- include/netsurf/plot_style.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h index 15069a52b..c4060926b 100644 --- a/include/netsurf/plot_style.h +++ b/include/netsurf/plot_style.h @@ -170,6 +170,11 @@ typedef struct plot_font_style { (((c0 & 0x00ff00) * 151) >> 16) + \ (((c0 & 0xff0000) * 28) >> 24)) +/* Choose either black or white, depending on which is nearest to the + * percieved lightness of the supplied colour, c0. */ +#define colour_to_bw_nearest(c0) \ + ((colour_lightness(c0) > (0xff / 2)) ? 0xffffff : 0x000000) + /* Choose either black or white, depending on which is furthest from the * percieved lightness of the supplied colour, c0. */ #define colour_to_bw_furthest(c0) \ -- cgit v1.2.3