npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

klar-plugin-cvd-brettel

v1.0.1

Published

klar plugin: color-vision-deficiency confusability metric for full dichromacy (Brettel 1997) — deuteranopia, protanopia, tritanopia.

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-brettel

Usage

# 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 registered

A 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).