summaryrefslogtreecommitdiff
path: root/include/netsurf
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2020-02-23 16:56:15 +0000
committerMichael Drake <michael.drake@codethink.co.uk>2020-02-23 17:38:14 +0000
commit6783deba4e209461fd8105b9b46dbcacefed6b6f (patch)
tree9577ddefbac3c8b4ebc8bfebffac730256c12e23 /include/netsurf
parent8a834918e30cd1924b2a3a4840a94445d55b5965 (diff)
downloadnetsurf-6783deba4e209461fd8105b9b46dbcacefed6b6f.tar.gz
netsurf-6783deba4e209461fd8105b9b46dbcacefed6b6f.tar.bz2
Plot style: Split lightness calc out of colour_to_bw_furthest macro.
Diffstat (limited to 'include/netsurf')
-rw-r--r--include/netsurf/plot_style.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/netsurf/plot_style.h b/include/netsurf/plot_style.h
index f1b617231..692192f17 100644
--- a/include/netsurf/plot_style.h
+++ b/include/netsurf/plot_style.h
@@ -153,13 +153,16 @@ typedef struct plot_font_style {
(((((c0 & 0xff00ff) + (c1 & 0xff00ff)) >> 1) & 0xff00ff) | \
((((c0 & 0x00ff00) + (c1 & 0x00ff00)) >> 1) & 0x00ff00))
+/* Get the percieved lightness of the supplied colour, c0. */
+#define colour_lightness(c0) \
+ ((((c0 & 0x0000ff) * 77) >> 8) + \
+ (((c0 & 0x00ff00) * 151) >> 16) + \
+ (((c0 & 0xff0000) * 28) >> 24))
+
/* 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) \
- ((((((c0 & 0x0000ff) * 77) >> 8) + \
- (((c0 & 0x00ff00) * 151) >> 16) + \
- (((c0 & 0xff0000) * 28) >> 24)) > \
- (0xff / 2)) ? 0x000000 : 0xffffff)
+ ((colour_lightness(c0) > (0xff / 2)) ? 0x000000 : 0xffffff)
/* Mix two colours according to the proportion given by p, where 0 <= p <= 255
* p = 0 gives result ==> c1, p = 255 gives result ==> c0 */