From e0a4b50e87504bdc4f0bed8d68e3e2bd4798642c Mon Sep 17 00:00:00 2001 From: Michael Drake Date: Fri, 10 Jul 2009 19:53:30 +0000 Subject: Move colour blend routine from html_redraw to plot_style and make it a define. svn path=/trunk/netsurf/; revision=8451 --- desktop/plot_style.h | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'desktop/plot_style.h') diff --git a/desktop/plot_style.h b/desktop/plot_style.h index 03bb69f91..9de9cbf97 100644 --- a/desktop/plot_style.h +++ b/desktop/plot_style.h @@ -28,31 +28,40 @@ #define WIDGET_BLOBC 0x000000 /* Darken a colour by taking three quaters of each channels intensity */ -#define darken_colour(c1) \ - ((((3 * (c1 >> 16)) >> 2) << 16) | \ - (((3 * ((c1 >> 8) & 0xff)) >> 2) << 8) | \ +#define darken_colour(c1) \ + ((((3 * (c1 >> 16)) >> 2) << 16) | \ + (((3 * ((c1 >> 8) & 0xff)) >> 2) << 8) | \ (((3 * (c1 & 0xff)) >> 2) << 0)) /* Darken a colour by taking nine sixteenths of each channels intensity */ -#define double_darken_colour(c1) \ - ((((9 * (c1 >> 16)) >> 4) << 16) | \ - (((9 * ((c1 >> 8) & 0xff)) >> 4) << 8) | \ +#define double_darken_colour(c1) \ + ((((9 * (c1 >> 16)) >> 4) << 16) | \ + (((9 * ((c1 >> 8) & 0xff)) >> 4) << 8) | \ (((9 * (c1 & 0xff)) >> 4) << 0)) /* Lighten a colour by taking three quaters of each channels intensity - * and adding a full quater + * and adding a full quater */ #define lighten_colour(c1) \ (((((3 * (c1 >> 16)) >> 2) + 64) << 16) | \ ((((3 * ((c1 >> 8) & 0xff)) >> 2) + 64) << 8) | \ ((((3 * (c1 & 0xff)) >> 2) + 64) << 0)) -/* Lighten a colour by taking nine sixteenths of each channels intensity and adding a full intensity 7/16ths */ -#define double_lighten_colour(c1) \ - (((((9 * (c1 >> 16)) >> 4) + 112) << 16) | \ - ((((9 * ((c1 >> 8) & 0xff)) >> 4) + 112) << 8) | \ +/* Lighten a colour by taking nine sixteenths of each channels intensity and + * adding a full intensity 7/16ths */ +#define double_lighten_colour(c1) \ + (((((9 * (c1 >> 16)) >> 4) + 112) << 16) | \ + ((((9 * ((c1 >> 8) & 0xff)) >> 4) + 112) << 8) | \ ((((9 * (c1 & 0xff)) >> 4) + 112) << 0)) +/* Blend two colours by taking half the intensity of each channel in the first + * colour and adding them to half the intensity of each channel in the second + * colour */ +#define blend_colour(c0, c1) \ + ((((c0 >> 16) + (c1 >> 16)) >> 1) << 16) | \ + (((((c0 >> 8) & 0xff) + ((c1 >> 8) & 0xff)) >> 1) << 8) | \ + ((((c0 & 0xff) + (c1 & 0xff)) >> 1) << 0) + typedef enum { PLOT_OP_TYPE_NONE = 0, /**< No operation */ PLOT_OP_TYPE_SOLID, /**< Solid colour */ @@ -64,7 +73,7 @@ typedef struct { plot_operation_type_t stroke_type; int stroke_width; colour stroke_colour; - plot_operation_type_t fill_type; + plot_operation_type_t fill_type; colour fill_colour; } plot_style_t; -- cgit v1.2.3