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 🙏

© 2024 – Pkg Stats / Ryan Hefner

color-blind

v0.1.3

Published

Simulate color blindness by converting RGB hex codes

Downloads

4,529

Readme

color-blind

NPM version Build Status Code Climate Coverage Status Dependency Status devDependency Status

NPM

Description

Simulate color blindness by converting RGB hex codes. This is a node.js port of the daltonize code by mudcu.be. See Links for more information.

Getting Started

Install the module with: npm install color-blind

var blinder = require('color-blind');
blinder.protanopia('#42dead'); // result: "#d1c4a0"

Color Blindness Table

| Group | | | | |----------------------------------------------------|------------------------------------|-----------------------------|--------------------------| | Trichromat3 good cones |Normal | | | | Anomalous Trichromat2 good cones, 1 bad |Protanomalylow red |Deuteranomalylow green|Tritanomalylow blue| | Dichromat2 good cones, 1 blind |Protanopiano red |Deuteranopiano green |Tritanopia no blue | | Monochromat1 good cone, 2 blind/bad |Achromatomalyalmost no color|Achromatopsiano color | |

Documentation

All the exported functions accept 2 parameters:

  • colorString - any valid CSS color string
  • returnRgb optional
    • if true, then an object containing RGB values is returned
    • if false or not passed, then a hex string is returned

blinder.protanomaly(colorString, returnRgb)

Part of the "Anomalous Trichromat" family of color blindness. The viewer sees low amounts of red.

Examples:

blinder.protanomaly("#42dead");
// result: "#9dcea5"
blinder.protanomaly("#42dead", false);
// result: "#9dcea5"
blinder.protanomaly("#42dead", true);
// result: {"R":156.81027381701807,"G":205.52274401697787,"B":164.8656701007824}

blinder.protanopia(colorString, returnRgb)

Part of the "Dichromat" family of color blindness. The viewer sees no red.

Examples:

blinder.protanopia("#42dead");
// result: "#d1c4a0"
blinder.protanopia("#42dead", false);
// result: "#d1c4a0"
blinder.protanopia("#42dead", true);
// result: {"R":208.70185885531413,"G":196.10716916953663,"B":160.21748158694382}

blinder.deuteranomaly(colorString, returnRgb)

Part of the "Anomalous Trichromat" family of color blindness. The viewer sees low amounts of green.

Examples:

blinder.deuteranomaly("#42dead");
// result: "#a5c9b3"
blinder.deuteranomaly("#42dead", false);
// result: "#a5c9b3"
blinder.deuteranomaly("#42dead", true);
// result: {"R":165.29136650372695,"G":201.41446893677266,"B":178.9125102904318}

blinder.deuteranopia(colorString, returnRgb)

Part of the "Dichromat" family of color blindness. The viewer sees no green.

Examples:

blinder.deuteranopia("#42dead");
// result: "#debeb6"
blinder.deuteranopia("#42dead", false);
// result: "#debeb6"
blinder.deuteranopia("#42dead", true);
// result: {"R":222.02929022014237,"G":189.6513083292142,"B":182.29108759925}

blinder.tritanomaly(colorString, returnRgb)

Part of the "Anomalous Trichromat" family of color blindness. The viewer sees low amounts of blue.

Examples:

blinder.tritanomaly("#42dead");
// result: "#56d8d1"
blinder.tritanomaly("#42dead", false);
// result: "#56d8d1"
blinder.tritanomaly("#42dead", true);
// result: {"R":86.14054005420464,"G":216.21898840123637,"B":209.23279525212993}

blinder.tritanopia(colorString, returnRgb)

Part of the "Dichromat" family of color blindness. The viewer sees no blue.

Examples:

blinder.tritanopia("#42dead");
// result: "#62d5e6"
blinder.tritanopia("#42dead", false);
// result: "#62d5e6"
blinder.tritanopia("#42dead", true);
// result: {"R":97.64942008517872,"G":212.91555320194286,"B":229.93724968191844}

blinder.achromatomaly(colorString, returnRgb)

Part of the "Monochromat" family of color blindness. The viewer sees the absence of most color.

Examples:

blinder.achromatomaly("#42dead");
// result: "#8ec7b5"
blinder.achromatomaly("#42dead", false);
// result: "#8ec7b5"
blinder.achromatomaly("#42dead", true);
// result: {"R":141.91089545454545,"G":198.63816818181814,"B":180.81998636363636}

blinder.achromatopsia(colorString, returnRgb)

Part of the "Monochromat" family of color blindness. The viewer sees no color at all.

Examples:

blinder.achromatopsia("#42dead");
// result: "#b9b9b9"
blinder.achromatopsia("#42dead", false);
// result: "#b9b9b9"
blinder.achromatopsia("#42dead", true);
// result: {"R":185.28855,"G":185.28855,"B":185.28855}

Links

Release History

v0.1.0 - Released June 21, 2014

  • initial release

License

Originally this project was licensed with:

Copyright (c) 2014 skratchdot
Licensed under the MIT license.

But the main algorithm is from code that included:

The Color Blindness Simulation function is
copyright (c) 2000-2001 by Matthew Wickline and the
Human-Computer Interaction Resource Network ( http://hcirn.com/ ).

It is used with the permission of Matthew Wickline and HCIRN,
and is freely available for non-commercial use. For commercial use, please
contact the Human-Computer Interaction Resource Network ( http://hcirn.com/ ).

I've included a note about HCIRN that was copied/edited from http://colorlab.wickline.org/colorblind/colorlab/engine.js:

HCIRN appears to no longer exist. This makes it impractical
for users to obtain permission from HCIRN in order to use
this file for commercial works. Instead:

This work is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License.
http://creativecommons.org/licenses/by-sa/4.0/

On 10/13/2022 the license needed to be updated to include CC-BY-SA-4.0.

For more information about this change, please see: https://github.com/skratchdot/color-blind/issues/3

Sorry for any issues this has caused.