Colouring in Python
Actively maintained. Last release 6 weeks ago, commits in 10 of the last 26 weeks. A safe choice.
pip install colouringsREADME as published on PyPI with version 2.1.0.
colourings
A lightweight Python library for creating, converting, comparing and interpolating colours. No runtime dependencies, typed throughout.
This project is a modernized fork of vaab/colour with additional formats, typing, revised channel ranges, and updated packaging.
Install
pip install colourings
Minimal example
from colourings import Color
c = Color("red")
c.hsl # HSL(hue=0.0, saturation=100.0, lightness=50.0)
c.oklch # OKLCH(lightness=0.6279..., chroma=0.2576..., hue=29.2338...)
c.mix("white", 0.3).hex_l # '#ff7765'
c.contrast_ratio("white") # 3.9984...
c.best_text_color() # <Color black>
c.darken(0.2).nearest_name() # 'firebrick'
What it does
| 15 formats | rgb hsl hsv hex web xyz lab lch oklab oklch cmyk yuv and alpha variants, each readable and writable |