Skip to main content

cvdsafe

Is your palette colorblind-safe? One import to check and fix color palettes for color-vision deficiency — protanopia, deuteranopia, tritanopia.

pip install cvdsafe
import cvdsafe as hue

hue.is_safe(["#d7191c", "#1a9641"])            # False — red and green collapse under deutan/protan
hue.is_safe(["#0072b2", "#e69f00", "#009e73"]) # True  — an Okabe-Ito set stays distinct

hue.check_palette(["#d7191c", "#1a9641"])
# {'pass': False, 'types': {'deutan': {'conflicts': [{'a': '#d7191c', 'b': '#1a9641', ...}]}}}

hue.fix_palette(["#d7191c", "#1a9641"])["colors"]  # a safe palette near the originals
hue.simulate("#d7191c", "deutan")                  # how that red looks to a deuteranope

What it does

  • is_safe(colors) → True/False for the whole palette.
  • check_palette(colors) → every pair that stays distinct to normal vision but collapses under a deficiency, with the CIEDE2000 difference before and after simulation.
  • fix_palette(colors) → an adjusted palette that passes, separated along lightness, staying near the originals.
  • simulate(color, type) → the color as a given deficiency sees it.
  • check_contrast(fg, bg) → WCAG contrast ratio and AA/AAA pass.

How it decides

cvdsafe is a front door to opticquiz-cvd, which simulates deficiency with the Machado, Oliveira & Fernandes (2009) matrices and measures color difference with CIEDE2000. The method is published open access: https://doi.org/10.5281/zenodo.21310578

Every function here is opticquiz_cvd's, unchanged — the package adds the name and one convenience, so there is never a second copy of the colorimetry to drift.

Not a legal audit

A screening aid for the color-distinguishability axis of accessibility, not a WCAG/ADA audit, and no screen-based check is a clinical diagnosis.

Licence

MIT.

Metadata

Release files for cvdsafe 0.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 cvdsafe 0.1.0
File Size Uploaded
cvdsafe-0.1.0.tar.gz 3.8 kB Details

Built distribution (wheel)

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

Total release size: 7.9 kB

Release files / cvdsafe-0.1.0.tar.gz

Download URL cvdsafe-0.1.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ea6c13dbe450cf2d2af68b0fda948c6c3c54e633695696b37c2368acaacb0875
BLAKE2b-256 checksum
How to use checksums
a4975168258e1997c74eb1b4246b9e3a649bbf936bd8fe77ffb96555c2a77421
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / cvdsafe-0.1.0-py3-none-any.whl

Download URL cvdsafe-0.1.0-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b93bdb6c25484c6d730b5b9a945728cab4a4341b1f55d759cc509c32fb3b3c0
BLAKE2b-256 checksum
How to use checksums
55acc4cdb0ef589ebe7382f5f998adb5d9beec03cf75202f8f0c3377fd827b15
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release 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