Color

libsuou provides some utilities for the manipulation of colors.

In particular, conversion to and from RGB and OKLCH colors.

Terminal colors

class suou.color.Chalk(flags=(), ends=())

ANSI escape codes for terminal colors, similar to JavaScript’s chalk library.

Best used with Python 3.12+ that allows arbitrary nesting of f-strings.

Yes, I am aware colorama exists.

UNTESTED

New in 0.7.0

Note: instance is chalk and can be used as-is

Web colors

class suou.color.RGBColor(red, green, blue)

Representation of a color in the sRGB / TrueColor (0 to 255) space.

Useful for theming.

Changed in 0.12.0: name is now RGBColor, with WebColor being an alias. Added conversions to and from OKLCH, OKLab, sRGB, and XYZ.

suou.color.WebColor

alias of RGBColor

class suou.color.LinearRGBColor(red, green, blue)

Represent a color in the linear RGB space.

New in 0.12.0

class suou.color.XYZColor(x, y, z)

Represent a color in the XYZ color space.

New in 0.12.0

class suou.color.OKLabColor(l, a, b)

Represent a color in the OKLab color space.

New in 0.12.0

class suou.color.OKLCHColor(l, c, h)

Represent a color in the OKLCH color space.

Warning: conversion to RGB is not bound checked yet!

New in 0.12.0