Skip to content

Colour

Module Visual.Colour

In overview:

Parsing

When working with colour you may need to use Colour.resolve to parse colour. It will parse human-friendly colours (“purple”), hex (“#ffffff”), CSS variables (“—fg”), CSS functions (“hsl(20deg, 50%, 50%))” and structured data: {h:0.5, s:0.1, l:0.5}. The return value for resolve can be passed to Colour.toString for setting to CSS styles, canvas drawing etc.

You can do this in one step via Colour.resolveToString .

If you want a structured object, albeit in simple form, Colour.toHsl and Colour.toRgb will convert to objects like { h, s, l, opacity } and { r, g, b, opacity }.