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

colourability

v0.2.1

Published

Color-blindness and grayscale filters for any webpage via SVG feColorMatrix

Readme

colourability

Test and improve color accessibility on real webpages with one tiny, zero-dependency TypeScript library.

colourability applies color transformations at the page level using a single SVG feColorMatrix, so it affects the entire DOM including Videos and Canvas elements.

Use it to:

  • simulate common color-vision deficiencies (protanopia, deuteranopia, tritanopia)
  • apply daltonization-style compensation matrices
  • tune strength live with intensity (0..1)
  • run custom 20-value matrices when needed

See it in action

The interactive demo applies the same filter to the whole page—images, <video>, <canvas>, and the rest of the DOM—so you can compare simulation and daltonization in context.

The recording lives next to the live demo in demo/. It is not included in the npm package (package.json "files"), so the published tarball stays small; GitHub renders it from the repository.

Install

npm install colourability

Usage

import Colourability from 'colourability';

const c11y = new Colourability();

// Simulate deuteranopia at full strength
c11y.apply('simulateColorBlindness/deuteranopia', { intensity: 1 });

// Tune effect strength while active
c11y.setIntensity(0.7);

// Remove filter and restore prior page state
colourability.remove();

Color-blindness workflows

1) Simulate what users may see


// Red-cone deficiency simulation
c11y.apply('simulateColorBlindness/protanopia');

// Green-cone deficiency simulation
c11y.apply('simulateColorBlindness/deuteranopia');

// Blue-cone deficiency simulation
c11y.apply('simulateColorBlindness/tritanopia');

2) Apply daltonization-style compensation


// Compensation preset (linear heuristic matrix)
c11y.apply('daltonizeColorBlindness/deuteranopia', { intensity: 1 });
c11y.setIntensity(0.85);

3) Compare quickly with a simple toggle


c11y.apply('simulateColorBlindness/deuteranopia');

// ... inspect UI ...

c11y.remove();

Built-in presets

Built-in ids use category/subname:

| Id | Purpose | |----|---------| | simulateColorBlindness/protanopia | Simulate red-cone (L) deficiency | | simulateColorBlindness/deuteranopia | Simulate green-cone (M) deficiency | | simulateColorBlindness/tritanopia | Simulate blue-cone (S) deficiency | | daltonizeColorBlindness/protanopia | Compensation heuristic (2I - M_sim) | | daltonizeColorBlindness/deuteranopia | Compensation heuristic (2I - M_sim) | | daltonizeColorBlindness/tritanopia | Compensation heuristic (2I - M_sim) | | visual/grayscale | BT.709 luminance grayscale | | fun/sepia | Stylized sepia | | fun/invert | Stylized invert |

intensity is always 0..1 and interpolates each matrix coefficient toward identity.


Custom matrix

Pass a 20-number feColorMatrix values string (row-major, same format as built-ins). For example, the identity (no-op) matrix:


const IDENTITY =
  '1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0';

c11y.applyMatrix(IDENTITY, { intensity: 0.5 });

API

  • apply(name, options?) — inject/update SVG filter and set filter: url(#__colourability-active__) on <html>
  • applyMatrix(matrix, options?) — same as apply, but with a raw 20-coefficient matrix string
  • remove() — remove SVG and restore the previous filter style
  • setIntensity(value) — adjust strength while a filter is active (preset or custom matrix)
  • list() — built-in preset ids
  • getState(){ active, customMatrix, options }active is set for built-ins; customMatrix is set when applyMatrix was used

Why this approach works

A hidden <svg> in <head> defines <filter id="__colourability-active__"> with color-interpolation-filters="linearRGB". The root element then references it via CSS filter: url(#__colourability-active__).

This means:

  • one consistent mechanism for grayscale, simulation, and daltonization
  • no fullscreen overlay hacks
  • pointer events and interaction model stay natural

Browser script (IIFE / UMD)

After building, load dist/colourability.min.js and use the global Colourability constructor.


Versioning (0.x)

While the major version is 0, minor releases may include breaking API or preset-id changes. Pin the version range you need for production.

Contributing

See CONTRIBUTING.md.

License

MIT — see LICENSE.