NAME
colour/palette - Colour palette helpers.
SYNOPSIS
from colour/palette import
rgb,
hsl,
from_rgb,
from_hsl,
lighten,
complement,
triad;
say( rgb("purple") );
say( lighten( "#336699", 10 ) );
say( triad( "tomato" ) );
DESCRIPTION
This pure-Zuzu module builds on std/colour to convert colours between hexadecimal, RGB, and HSL forms, adjust lightness and saturation, mix two colours, rotate hue, and generate small palettes.
All colour arguments are parsed with parse_colour, so CSS colour keywords and three- or six-digit hexadecimal colours are accepted.
EXPORTED FUNCTIONS
rgb(String colour)Return a dictionary with
r,g, andbchannel values from 0 to 255.hsl(String colour)Return a dictionary with
hin degrees andsandlas percentages.from_rgb(Number r, Number g, Number b)Return a normalized lowercase hexadecimal colour.
from_hsl(Number h, Number s, Number l)Return a normalized lowercase hexadecimal colour.
mix(String left, String right, Number weight := 0.5)Mix two colours.
weightis the fraction ofrightin the result.lighten(String colour, Number amount)darken(String colour, Number amount)saturate(String colour, Number amount)desaturate(String colour, Number amount)Adjust HSL percentage channels by
amountpercentage points.rotate_hue(String colour, Number degrees)complement(String colour)analogous(String colour, Number angle := 30)triad(String colour)tetrad(String colour)monochrome(String colour, Number steps := 5, Number spread := 30)
COPYRIGHT AND LICENCE
colour/palette is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.