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/Falsefor 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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cvdsafe-0.1.0.tar.gz.
File metadata
- Download URL: cvdsafe-0.1.0.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea6c13dbe450cf2d2af68b0fda948c6c3c54e633695696b37c2368acaacb0875
|
|
| MD5 |
bd084ca396301f41991b6935f0e88dc6
|
|
| BLAKE2b-256 |
a4975168258e1997c74eb1b4246b9e3a649bbf936bd8fe77ffb96555c2a77421
|
File details
Details for the file cvdsafe-0.1.0-py3-none-any.whl.
File metadata
- Download URL: cvdsafe-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b93bdb6c25484c6d730b5b9a945728cab4a4341b1f55d759cc509c32fb3b3c0
|
|
| MD5 |
d9094fa59aa86b4105edc5e96e07807b
|
|
| BLAKE2b-256 |
55acc4cdb0ef589ebe7382f5f998adb5d9beec03cf75202f8f0c3377fd827b15
|