modules/colour/palette.zzm

colour-palette-0.0.1 documentation

Package

Name
colour-palette
Version
0.0.1
Uploaded
2026-05-13 17:33:17
Dependencies
Metadata
zuzu-distribution.json
Archive
Download .tar.gz

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, and b channel values from 0 to 255.

  • hsl(String colour)

    Return a dictionary with h in degrees and s and l as 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. weight is the fraction of right in 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 amount percentage 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.