Skip to content


A colour is a 3-byte array of the form 0xRRGGBB. For example, full red would be 0xff0000. In general, wherever a colour is expected, either a pre-defined colour from this module can be used, or a custom 3-byte array.

Built-in named colours

Any colour from the list below can used used either by referencing the value directly (.gg.colour.Crimson), or by referring to it as a symbol (`crimson). If referring to the colour as a symbol, case does not matter.

Colour palettes

There are a number of built-in colour palettes available, as well as functions for generating gradients for use as colour scales.

See .gg.colour.brewer for a set of colour palettes which can be used to generate gradient or be used as categorical colour scales.

The default categorical colour scale uses the .gg.colour.cat10 colour palette, which provides 10 distinct colours. .gg.colour.cat20 is based on the same colours, but presented as dark-light pairs.


Return the brewer palette for the given name and colour count. Each available palette comes in a number of sets defined by the number of colours returned. For example, for a 6-value palette from yellow to green, run .gg.colour.brewer[`YlGn;6]. All available brewer palettes and their set options are visible below.


Name Type Description
palette symbol palette name (see example below)
n long colour count (see example below)


Type Description
byte[][] list of colours


10 distinct colours. The colours are displayed below.


20 distinct colours (10 colours in lightness pairs). The colours are displayed below.


Given a range of numeric values, and a value within that range, return a colour corresponding to the colour along a gradient.


Name Type Description
values_ number[] | number scalar within the source range min and max
min_ number source range min
max_ number source range max
color1 byte[] low colour on the gradient
color2 byte[] high colour on the gradient


Type Description
byte[] resulting colour along the gradient


 .gg.colour.gradient[til 5; 0; 10; .gg.colour.Red; .gg.colour.Blue]
 //=> 16711680 15073306 13369395 11731021 10027110i


Return an RGB colour (0xRRGGBB) from an HSL colour


Name Type Description
hsl float[]


Type Description


 0x0070cd ~ .gg.colour.rgbFromHSL .gg.colour.hsl 0x0070cd