klar-plugin-cvd-brettel
v1.0.1
Published
klar plugin: color-vision-deficiency confusability metric for full dichromacy (Brettel 1997) — deuteranopia, protanopia, tritanopia.
Maintainers
Readme
klar-plugin-cvd-brettel
A klar plugin that measures whether two colors stay distinguishable for a person with color blindness — specifically full dichromacy, using the Brettel, Viénot & Mollon (1997) simulation.
It adds three contrast types:
| --type | Deficiency |
|---|---|
| cvd-deuteranopia | no functioning M (green) cones |
| cvd-protanopia | no functioning L (red) cones |
| cvd-tritanopia | no functioning S (blue) cones |
What it measures
Each type simulates both input colors as that dichromat would see them, then returns the CIEDE2000 (ΔE₀₀) between the simulated colors:
- high → the two colors stay clearly separated (good)
- low → they collapse together / become confusable (a real accessibility problem)
Higher-is-better, integer-rounded — same polarity and rounding as klar's built-in
deltaE, so it composes with the rest of klar.
Install
Install alongside klar (klar discovers it automatically by the klar-plugin-*
convention):
npm install -g klar-cli klar-plugin-cvd-brettelUsage
# a red and a green that look very different to normal vision...
$ klar contrast "#d40000" "#00a000" --type deltaE -q
72
# ...nearly collapse for a deuteranope:
$ klar contrast "#d40000" "#00a000" --type cvd-deuteranopia -q
7
# but stay distinct under tritanopia (which spares the red–green axis):
$ klar contrast "#d40000" "#00a000" --type cvd-tritanopia -q
62
$ klar plugins list # confirm the three types are registeredA common convention is to treat ΔE ≥ 11 as "still clearly distinct." That threshold is your policy to apply, though — the plugin returns the raw number.
Why Brettel (and why all three types here)
Brettel 1997 is the reference-accuracy model for full dichromacy and the only
common method that handles tritanopia correctly (the dichromat gamut is two
half-planes in LMS, which a single matrix can't represent). For anomalous
trichromacy (partial color blindness — the more common form), see the companion
klar-plugin-cvd-machado.
Attribution & license
- Plugin code: MIT.
- Simulation constants vendored from libDaltonLens (public domain), which provides the corrected Brettel/Viénot matrices.
- Brettel, H., Viénot, F., & Mollon, J. D. (1997). Computerized simulation of color appearance for dichromats. JOSA A, 14(10).
