Simulate color blindness by converting RGB hex codes.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
test
.gitignore
.jshintrc
.npmignore
.travis.yml run travis on latest node version Jun 22, 2014
LICENSE-MIT
README.md
gulpfile.js initial commit Jun 21, 2014
package.json

README.md

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
Trichromat
3 good cones
Normal
Anomalous Trichromat
2 good cones, 1 bad
Protanomaly
low red
Deuteranomaly
low green
Tritanomaly
low blue
Dichromat
2 good cones, 1 blind
Protanopia
no red
Deuteranopia
no green
Tritanopia
no blue
Monochromat
1 good cone, 2 blind/bad
Achromatomaly
almost no color
Achromatopsia
no 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

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