Skip to main content

safepalette

Colorblind-safe color palettes — generate, check, and fix. Ask for N safe colors, test a palette you have, or repair one that fails — protanopia, deuteranopia, tritanopia.

pip install safepalette
import safepalette as sp

sp.generate(5)                          # 5 colorblind-safe hex colors (Okabe-Ito based)
sp.is_safe(["#d7191c", "#1a9641"])      # False — red & green collapse under deutan/protan
sp.fix(["#d7191c", "#1a9641"])["colors"] # a safe palette near the originals
sp.OKABE_ITO                            # the canonical 8-color safe palette

API

  • generate(n, **opts) → up to n colorblind-safe hex colors. n <= 8 is the Okabe–Ito palette (safe by design); above 8 it extends only with colors that keep the whole set passing. Large n may return fewer than n — never an unsafe color.
  • is_safe(colors, **opts)True/False.
  • fix(colors, **opts){"colors", "drift", "pass", "residual"}, a safe palette near the originals.
  • check(colors, **opts) → the full per-type conflict report.

How it decides

check and fix are opticquiz-cvd's check_palette and fix_palette — Machado, Oliveira & Fernandes (2009) + CIEDE2000, open access: https://doi.org/10.5281/zenodo.21310578 . The generator is seeded with the Okabe–Ito safe palette (Wong, Nature Methods, 2011). No colorimetry is reimplemented here.

Not a legal audit

A screening/design aid for the color-distinguishability axis, not a WCAG/ADA audit.

Licence

MIT.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safepalette-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safepalette-0.1.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file safepalette-0.1.0.tar.gz.

File metadata

  • Download URL: safepalette-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for safepalette-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8cb2be9b16bff6778410e365877708116b22761221deeb4fcff8f3b3357c8870
MD5 3f5e186f05be9e148ae7f3c53cf1c4b1
BLAKE2b-256 a1812f0c0319a70d935989eb9e1a769e0441c5e83756483b5294fe0288693e37

See more details on using hashes here.

File details

Details for the file safepalette-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: safepalette-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for safepalette-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4a1327d5c12d283ff21bc4ae0da090a46c3f85db501bb033f87a29b50e10da1d
MD5 492c0cd2ec342b1b8e6c0dd7583c3c7d
BLAKE2b-256 d9234628fd9c2fbcae5fe52d7fd0216d76d099603ac5a6b684040dffc717a779

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

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