coolor 0.5.0

conversion between color formats
Documentation

MIT Latest Version docs Chat on Miaou

Definition of ANSI, RGB and HSL color types and all the conversions between them.

There are many other color conversion crates. This one is no-std and may be useful when you're interested into

  • variations of an ANSI color for your TUI application, for example fading, lightening, darkening, with compatibility with terminals that don't support RGB.
  • translations of color schemes
  • automatic downgrading of RGB color schemes for non RGB terminals
  • automated building of harmonious color schemes with guarantees of contrast
  • etc.

Coolor is used in SafeCloset to dynamically fade the background behind a dialog:

img

Be warned that the ANSI range is intrinsically limited to 240 colors and that not all intuitive operations will give good results.

Coolor doesn't contain functions to print on the terminal, but the colors can be used in other crates. There's an optional feature for conversion from and into Crossterm colors.

Included Examples

ansi-variations

Luminosity and saturation variations of all 240 ANSI colors, with all variants still ANSI colors.

ansi-variations

ansi-mix

Several ways to mix colors

ansi-mix