NetSurf
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
plot_style.h File Reference

plotter style interfaces, generic styles and style colour helpers. More...

#include <stdint.h>
#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/types.h"
Include dependency graph for plot_style.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  plot_style_s
 Plot style for stroke/fill plotters. More...
 
struct  plot_font_style
 Font style for plotting. More...
 

Macros

#define WIDGET_BASEC   0xd9d9d9
 light grey widget base colour More...
 
#define WIDGET_BLOBC   0x000000
 black blob colour More...
 
#define NS_TRANSPARENT   0x01000000
 Transparent colour value. More...
 
#define PLOT_STYLE_RADIX   (10)
 22:10 fixed point More...
 
#define PLOT_STYLE_SCALE   (1 << PLOT_STYLE_RADIX)
 Scaling factor for plot styles. More...
 
#define plot_style_int_to_fixed(v)   ((v) << PLOT_STYLE_RADIX)
 
#define plot_style_fixed_to_int(v)   ((v) >> PLOT_STYLE_RADIX)
 
#define plot_style_fixed_to_float(v)   (((float)v) / PLOT_STYLE_SCALE)
 
#define plot_style_fixed_to_double(v)   (((double)v) / PLOT_STYLE_SCALE)
 
#define half_darken_colour(c1)
 
#define darken_colour(c1)
 
#define double_darken_colour(c1)
 
#define half_lighten_colour(c1)
 
#define lighten_colour(c1)
 
#define double_lighten_colour(c1)
 
#define blend_colour(c0, c1)
 
#define colour_lightness(c0)
 Obtain the luminance of a colour according to ITU BT.601. More...
 
#define colour_to_bw_nearest(c0)    ((colour_lightness(c0) > (0xff / 2)) ? 0xffffff : 0x000000)
 
#define colour_to_bw_furthest(c0)    ((colour_lightness(c0) > (0xff / 2)) ? 0x000000 : 0xffffff)
 
#define mix_colour(c0, c1, p)
 
#define red_from_colour(c)    ((c ) & 0xff)
 
#define green_from_colour(c)    ((c >> 8) & 0xff)
 
#define blue_from_colour(c)    ((c >> 16) & 0xff)
 
#define colour_rb_swap(c)
 

Typedefs

typedef int32_t plot_style_fixed
 
typedef struct plot_style_s plot_style_t
 Plot style for stroke/fill plotters. More...
 
typedef struct plot_font_style plot_font_style_t
 Font style for plotting. More...
 

Enumerations

enum  plot_operation_type_t { PLOT_OP_TYPE_NONE = 0 , PLOT_OP_TYPE_SOLID , PLOT_OP_TYPE_DOT , PLOT_OP_TYPE_DASH }
 Type of plot operation. More...
 
enum  plot_font_generic_family_t {
  PLOT_FONT_FAMILY_SANS_SERIF = 0 , PLOT_FONT_FAMILY_SERIF , PLOT_FONT_FAMILY_MONOSPACE , PLOT_FONT_FAMILY_CURSIVE ,
  PLOT_FONT_FAMILY_FANTASY , PLOT_FONT_FAMILY_COUNT
}
 Generic font family type. More...
 
enum  plot_font_flags_t { FONTF_NONE = 0 , FONTF_ITALIC = 1 , FONTF_OBLIQUE = 2 , FONTF_SMALLCAPS = 4 }
 Font plot flags. More...
 
enum  plot_colour_component { PLOT_COLOUR_COMPONENT_RED , PLOT_COLOUR_COMPONENT_GREEN , PLOT_COLOUR_COMPONENT_BLUE , PLOT_COLOUR_COMPONENT_ALPHA }
 Colour components. More...
 

Functions

static colour colour_engorge_component (colour col, bool dark, enum plot_colour_component comp)
 Engorge a particular colour channel. More...
 

Variables

plot_style_tplot_style_fill_white
 
plot_style_tplot_style_fill_red
 
plot_style_tplot_style_fill_black
 
plot_style_t const *const plot_style_content_edge
 
plot_style_t const *const plot_style_padding_edge
 
plot_style_t const *const plot_style_margin_edge
 
plot_style_t const *const plot_style_broken_object
 
plot_font_style_t const *const plot_fstyle_broken_object
 
plot_style_tplot_style_caret
 
plot_style_tplot_style_fill_wbasec
 
plot_style_tplot_style_fill_darkwbasec
 
plot_style_tplot_style_fill_lightwbasec
 
plot_style_tplot_style_fill_wblobc
 
plot_style_tplot_style_stroke_wblobc
 
plot_style_tplot_style_stroke_darkwbasec
 
plot_style_tplot_style_stroke_lightwbasec
 
plot_font_style_t const *const plot_style_font
 

Detailed Description

plotter style interfaces, generic styles and style colour helpers.

Definition in file plot_style.h.

Macro Definition Documentation

◆ blend_colour

#define blend_colour (   c0,
  c1 
)
Value:
(((((c0 & 0xff00ff) + (c1 & 0xff00ff)) >> 1) & 0xff00ff) | \
((((c0 & 0x00ff00) + (c1 & 0x00ff00)) >> 1) & 0x00ff00))

Definition at line 163 of file plot_style.h.

◆ blue_from_colour

#define blue_from_colour (   c)     ((c >> 16) & 0xff)

Definition at line 213 of file plot_style.h.

◆ colour_lightness

#define colour_lightness (   c0)
Value:
((((c0 & 0x0000ff) * 77) >> 8) + \
(((c0 & 0x00ff00) * 151) >> 16) + \
(((c0 & 0xff0000) * 30) >> 24))

Obtain the luminance of a colour according to ITU BT.601.

ITU BT.601 formula is Y = 0.299 R + 0.587 G + 0.114 B actual values are Y = 76/255 R + 150/255 G + 29/255 B Y = 0.298 R + 0.588 G + 0.113 B

Note
if additional performance is required this could be altered to Y = 0.375 R + 0.5 G + 0.125 B with Y = (R << 1 + R + G << 2 + B) >> 3

Definition at line 181 of file plot_style.h.

◆ colour_rb_swap

#define colour_rb_swap (   c)
Value:
(((0x000000ff & c) << 16) | \
((0x0000ff00 & c) ) | \
((0x00ff0000 & c) >> 16))

Definition at line 217 of file plot_style.h.

◆ colour_to_bw_furthest

#define colour_to_bw_furthest (   c0)     ((colour_lightness(c0) > (0xff / 2)) ? 0x000000 : 0xffffff)

Definition at line 193 of file plot_style.h.

◆ colour_to_bw_nearest

#define colour_to_bw_nearest (   c0)     ((colour_lightness(c0) > (0xff / 2)) ? 0xffffff : 0x000000)

Definition at line 188 of file plot_style.h.

◆ darken_colour

#define darken_colour (   c1)
Value:
((((3 * (c1 & 0xff00ff)) >> 2) & 0xff00ff) | \
(((3 * (c1 & 0x00ff00)) >> 2) & 0x00ff00))

Definition at line 133 of file plot_style.h.

◆ double_darken_colour

#define double_darken_colour (   c1)
Value:
((((9 * (c1 & 0xff00ff)) >> 4) & 0xff00ff) | \
(((9 * (c1 & 0x00ff00)) >> 4) & 0x00ff00))

Definition at line 138 of file plot_style.h.

◆ double_lighten_colour

#define double_lighten_colour (   c1)
Value:
(((((9 * (c1 & 0xff00ff)) >> 4) + 0x700070) & 0xff00ff) | \
((((9 * (c1 & 0x00ff00)) >> 4) + 0x007000) & 0x00ff00))

Definition at line 156 of file plot_style.h.

◆ green_from_colour

#define green_from_colour (   c)     ((c >> 8) & 0xff)

Definition at line 209 of file plot_style.h.

◆ half_darken_colour

#define half_darken_colour (   c1)
Value:
((((7 * (c1 & 0xff00ff)) >> 3) & 0xff00ff) | \
(((7 * (c1 & 0x00ff00)) >> 3) & 0x00ff00))

Definition at line 128 of file plot_style.h.

◆ half_lighten_colour

#define half_lighten_colour (   c1)
Value:
(((((7 * (c1 & 0xff00ff)) >> 3) + 0x200020) & 0xff00ff) | \
((((7 * (c1 & 0x00ff00)) >> 3) + 0x002000) & 0x00ff00))

Definition at line 144 of file plot_style.h.

◆ lighten_colour

#define lighten_colour (   c1)
Value:
(((((3 * (c1 & 0xff00ff)) >> 2) + 0x400040) & 0xff00ff) | \
((((3 * (c1 & 0x00ff00)) >> 2) + 0x004000) & 0x00ff00))

Definition at line 150 of file plot_style.h.

◆ mix_colour

#define mix_colour (   c0,
  c1,
 
)
Value:
((((((c1 & 0xff00ff) * (255 - p)) + \
((c0 & 0xff00ff) * ( p)) ) >> 8) & 0xff00ff) | \
(((((c1 & 0x00ff00) * (255 - p)) + \
((c0 & 0x00ff00) * ( p)) ) >> 8) & 0x00ff00))

Definition at line 198 of file plot_style.h.

◆ NS_TRANSPARENT

#define NS_TRANSPARENT   0x01000000

Transparent colour value.

Definition at line 39 of file plot_style.h.

◆ plot_style_fixed_to_double

#define plot_style_fixed_to_double (   v)    (((double)v) / PLOT_STYLE_SCALE)

Definition at line 60 of file plot_style.h.

◆ plot_style_fixed_to_float

#define plot_style_fixed_to_float (   v)    (((float)v) / PLOT_STYLE_SCALE)

Definition at line 57 of file plot_style.h.

◆ plot_style_fixed_to_int

#define plot_style_fixed_to_int (   v)    ((v) >> PLOT_STYLE_RADIX)

Definition at line 54 of file plot_style.h.

◆ plot_style_int_to_fixed

#define plot_style_int_to_fixed (   v)    ((v) << PLOT_STYLE_RADIX)

Definition at line 51 of file plot_style.h.

◆ PLOT_STYLE_RADIX

#define PLOT_STYLE_RADIX   (10)

22:10 fixed point

Definition at line 42 of file plot_style.h.

◆ PLOT_STYLE_SCALE

#define PLOT_STYLE_SCALE   (1 << PLOT_STYLE_RADIX)

Scaling factor for plot styles.

Definition at line 45 of file plot_style.h.

◆ red_from_colour

#define red_from_colour (   c)     ((c ) & 0xff)

Definition at line 205 of file plot_style.h.

◆ WIDGET_BASEC

#define WIDGET_BASEC   0xd9d9d9

light grey widget base colour

Definition at line 33 of file plot_style.h.

◆ WIDGET_BLOBC

#define WIDGET_BLOBC   0x000000

black blob colour

Definition at line 36 of file plot_style.h.

Typedef Documentation

◆ plot_font_style_t

Font style for plotting.

◆ plot_style_fixed

typedef int32_t plot_style_fixed

Definition at line 48 of file plot_style.h.

◆ plot_style_t

typedef struct plot_style_s plot_style_t

Plot style for stroke/fill plotters.

Enumeration Type Documentation

◆ plot_colour_component

Colour components.

Enumerator
PLOT_COLOUR_COMPONENT_RED 
PLOT_COLOUR_COMPONENT_GREEN 
PLOT_COLOUR_COMPONENT_BLUE 
PLOT_COLOUR_COMPONENT_ALPHA 

Definition at line 223 of file plot_style.h.

◆ plot_font_flags_t

Font plot flags.

Enumerator
FONTF_NONE 
FONTF_ITALIC 
FONTF_OBLIQUE 
FONTF_SMALLCAPS 

Definition at line 101 of file plot_style.h.

◆ plot_font_generic_family_t

Generic font family type.

Enumerator
PLOT_FONT_FAMILY_SANS_SERIF 
PLOT_FONT_FAMILY_SERIF 
PLOT_FONT_FAMILY_MONOSPACE 
PLOT_FONT_FAMILY_CURSIVE 
PLOT_FONT_FAMILY_FANTASY 
PLOT_FONT_FAMILY_COUNT 

Number of generic families.

Definition at line 88 of file plot_style.h.

◆ plot_operation_type_t

Type of plot operation.

Enumerator
PLOT_OP_TYPE_NONE 

No operation.

PLOT_OP_TYPE_SOLID 

Solid colour.

PLOT_OP_TYPE_DOT 

Dotted plot.

PLOT_OP_TYPE_DASH 

Dashed plot.

Definition at line 65 of file plot_style.h.

Function Documentation

◆ colour_engorge_component()

static colour colour_engorge_component ( colour  col,
bool  dark,
enum plot_colour_component  comp 
)
inlinestatic

Engorge a particular colour channel.

Parameters
[in]colThe colour to engorge a component of.
[in]darkWhether col is a dark colour.
[in]compColour component to engorge.

Definition at line 237 of file plot_style.h.

References darken_colour, double_darken_colour, double_lighten_colour, lighten_colour, PLOT_COLOUR_COMPONENT_ALPHA, PLOT_COLOUR_COMPONENT_BLUE, PLOT_COLOUR_COMPONENT_GREEN, and PLOT_COLOUR_COMPONENT_RED.

Referenced by nscolour__get().

Here is the caller graph for this function:

Variable Documentation

◆ plot_fstyle_broken_object

plot_font_style_t const* const plot_fstyle_broken_object
extern

Definition at line 90 of file plot_style.c.

Referenced by html_redraw_box().

◆ plot_style_broken_object

plot_style_t const* const plot_style_broken_object
extern

Definition at line 79 of file plot_style.c.

Referenced by html_redraw_box().

◆ plot_style_caret

plot_style_t* plot_style_caret
extern

Definition at line 98 of file plot_style.c.

◆ plot_style_content_edge

plot_style_t const* const plot_style_content_edge
extern

Definition at line 52 of file plot_style.c.

Referenced by html_redraw_box().

◆ plot_style_fill_black

plot_style_t* plot_style_fill_black
extern

Definition at line 38 of file plot_style.c.

Referenced by ro_gui_status_bar_redraw(), and textplain_redraw().

◆ plot_style_fill_darkwbasec

plot_style_t* plot_style_fill_darkwbasec
extern

Definition at line 116 of file plot_style.c.

Referenced by html_redraw_radio().

◆ plot_style_fill_lightwbasec

plot_style_t* plot_style_fill_lightwbasec
extern

Definition at line 123 of file plot_style.c.

Referenced by form_redraw_select_menu(), and html_redraw_radio().

◆ plot_style_fill_red

plot_style_t* plot_style_fill_red
extern

Definition at line 44 of file plot_style.c.

Referenced by ro_gui_progress_bar_redraw_window().

◆ plot_style_fill_wbasec

plot_style_t* plot_style_fill_wbasec
extern

Definition at line 109 of file plot_style.c.

Referenced by html_redraw_checkbox(), and html_redraw_radio().

◆ plot_style_fill_wblobc

plot_style_t* plot_style_fill_wblobc
extern

Definition at line 131 of file plot_style.c.

Referenced by html_redraw_checkbox(), and html_redraw_radio().

◆ plot_style_fill_white

plot_style_t* plot_style_fill_white
extern

◆ plot_style_font

plot_font_style_t const* const plot_style_font
extern

Definition at line 165 of file plot_style.c.

Referenced by amiga_plugin_hack_redraw(), redraw_entry(), and svg_redraw_internal().

◆ plot_style_margin_edge

plot_style_t const* const plot_style_margin_edge
extern

Definition at line 68 of file plot_style.c.

Referenced by html_redraw_box().

◆ plot_style_padding_edge

plot_style_t const* const plot_style_padding_edge
extern

Definition at line 60 of file plot_style.c.

Referenced by html_redraw_box().

◆ plot_style_stroke_darkwbasec

plot_style_t* plot_style_stroke_darkwbasec
extern

Definition at line 146 of file plot_style.c.

Referenced by form_redraw_select_menu(), and html_redraw_checkbox().

◆ plot_style_stroke_lightwbasec

plot_style_t* plot_style_stroke_lightwbasec
extern

Definition at line 153 of file plot_style.c.

Referenced by html_redraw_checkbox().

◆ plot_style_stroke_wblobc

plot_style_t* plot_style_stroke_wblobc
extern

Definition at line 139 of file plot_style.c.

Referenced by html_redraw_checkbox().