Colour module

Colour module — colour parsing and string generation

Functions

Types and Values

Description

Functions

nk_colour_parse ()

gboolean
nk_colour_parse (const gchar *string,
                 NkColour *colour);

Tries to parse string to fill colour .

Accepted formats are a subset of the CSS4 colour values recommendation. Colour names, #hex, rgb(), hsl() and hwb() notations are supported.

If the function returns TRUE, colour is filled with the parsed values.

If the function returns FALSE, colour is left untouched.

Parameters

string

a string representing a colour

 

colour

the corresponding NkColour.

[out caller-allocates]

Returns

TRUE if string represents a valid colour, FALSE otherwise.


nk_colour_to_hex ()

const gchar *
nk_colour_to_hex (const NkColour *colour);

Generates a string representing the colour in CSS rgb() notation. Will generate an rgba() string if colour.alpha is not 0.

Parameters

colour

an NkColour

 

Returns

the rgb() string for colour


nk_colour_to_rgba ()

const gchar *
nk_colour_to_rgba (const NkColour *colour);

Types and Values

NkColour

typedef struct {
    gdouble red;
    gdouble green;
    gdouble blue;
    gdouble alpha;
} NkColour;

Members

gdouble red;

the red component

 

gdouble green;

the green component

 

gdouble blue;

the blue component

 

gdouble alpha;

the alpha component