libnkutils Colour format

Colour format — textual representation of NkColour

Colour strings

The colour string format is borrowed from the CSS4 colour values. Hexadecimal (#-prefixed) and decimal (rgb() format) RGB(A) notations are supported.

Here is a quick description:

#RRGGBB[AA], #RGB[A]

Each value is an hexadecimal value in the 0x00-0xff range.

The alpha value is an extension of the CSS3 notation and is optional.

The single-letter version means duplicating the character (e.g. "#123" means "#112233").

rgb(red, green, blue), rgba(red, green, blue, alpha)

Each colour value can be an number in the 0-255 range or a percentage value.

The alpha value is a floating point or a percentage value.

hsl(hue, saturation, lightness), hsla(hue, saturation, lightness, alpha)

Hue is an angle either in degrees (unit deg or no unit), gradians (unit grab), radians (unit rad) or turns (unit turn, a floating point number from 0 to 1).

The saturation and lightness values are percentage values.

The alpha value is the same as the rgba() notation.

hwb(hue, whiteness, blackness[, alpha])

Hue is the same as the hsl() notation.

The whiteness and blackness values are percentage values.

The alpha value is the same as the rgba() notation.