Skip to main content

colourings

PyPI - Version PyPI - Python Version PyPI Downloads codecov Documentation

A lightweight Python library for creating, converting, comparing and interpolating colours. No runtime dependencies, typed throughout.

📖 Read the documentation

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 Creating colours
CSS Color 4 & 5 rgb() hsl() lab() lch() oklab() oklch(), color-mix(), color() with display-p3 / a98-rgb / rec2020, plus to_css() output CSS syntax
Gradients range_to and color_scale, interpolating in hsl lab lch oklab oklch, either way round the hue circle, alpha included Gradients
Adjustment lighten darken saturate desaturate with absolute or relative steps, grayscale invert rotate_hue mix, and the hue harmonies Adjusting
WCAG contrast contrast_ratio relative_luminance is_readable best_text_color is_dark Contrast
Perceptual distance delta_e over CIE76, CIE94, CIEDE2000 and Oklab, and nearest_name Difference
Compositing over and blend through all sixteen CSS blend modes, encoded or linear Compositing
Gamut checking in_srgb_gamut, to ask before a value gets clipped Ranges and gamut
Stable picking pick_for, mapping any object to the same colour in every process Equality and picking

Correctness

Most of this library is arithmetic on published constants, and a wrong constant there does not raise — it returns a plausible colour that is simply wrong. So every constant is either quoted from a citable source or derived in exact arithmetic, and anything whose constants could not be confirmed raises instead of guessing.

CIEDE2000 is checked against all 34 pairs of the published Sharma–Wu–Dalal test data. The CSS wide-gamut matrices are each derived twice, independently. Coverage is 100% of statements and branches, and every example in the README and the docs is executed by the test suite with its claimed output checked.

Contributing

Bug reports, colour-science corrections and pull requests are welcome. CONTRIBUTING.md describes the checks CI runs, all of which you can run locally, and what a change needs before it can be merged.

Security

To report a vulnerability, use GitHub's private reporting rather than a public issue. SECURITY.md sets out what is in scope — the short version is that colourings performs no I/O, opens no network connections and has no runtime dependencies, which leaves crafted inputs and the release process itself.

License

BSD-3-Clause. See LICENSE.

Metadata

Release files for colourings 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colourings 2.1.0
File Size Uploaded Provenance Actions
colourings-2.1.0.tar.gz 125.7 kB With provenance Details for colourings-2.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for colourings 2.1.0
File Interpreter ABI Platform Actions
colourings-2.1.0-py3-none-any.whl Python 3 none any Details for colourings-2.1.0-py3-none-any.whl

Total release size: 192.2 kB

Release files / colourings-2.1.0.tar.gz

Download URL colourings-2.1.0.tar.gz
Size 125.7 kB
Tags Source
SHA-256 checksum
How to use checksums
4edcbd5195aec5195402de501cb9fef918efdaaec02f8ca8ee91909c389d52a5
BLAKE2b-256 checksum
How to use checksums
cf9c1886e5b093380ede17170d8a8f31b69bc50fbd2c4d4bdd5221e9af6db220
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Release files / colourings-2.1.0-py3-none-any.whl

Download URL colourings-2.1.0-py3-none-any.whl
Size 66.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4827ec65f938acb8dbad394613dfdb5933904dc3001bc38fecf3b64a54d16ff0
BLAKE2b-256 checksum
How to use checksums
def8e0fd201331de37c432eda5989d8547415bf9a277e35e46d870e23290c62e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

Security for colourings 2.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for colourings-2.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 18, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page