color-blind
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');
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");
blinder.protanomaly("#42dead", false);
blinder.protanomaly("#42dead", true);
blinder.protanopia(colorString, returnRgb)
Part of the "Dichromat" family of color blindness. The viewer sees no red.
Examples:
blinder.protanopia("#42dead");
blinder.protanopia("#42dead", false);
blinder.protanopia("#42dead", true);
blinder.deuteranomaly(colorString, returnRgb)
Part of the "Anomalous Trichromat" family of color blindness. The viewer sees low amounts of green.
Examples:
blinder.deuteranomaly("#42dead");
blinder.deuteranomaly("#42dead", false);
blinder.deuteranomaly("#42dead", true);
blinder.deuteranopia(colorString, returnRgb)
Part of the "Dichromat" family of color blindness. The viewer sees no green.
Examples:
blinder.deuteranopia("#42dead");
blinder.deuteranopia("#42dead", false);
blinder.deuteranopia("#42dead", true);
blinder.tritanomaly(colorString, returnRgb)
Part of the "Anomalous Trichromat" family of color blindness. The viewer sees low amounts of blue.
Examples:
blinder.tritanomaly("#42dead");
blinder.tritanomaly("#42dead", false);
blinder.tritanomaly("#42dead", true);
blinder.tritanopia(colorString, returnRgb)
Part of the "Dichromat" family of color blindness. The viewer sees no blue.
Examples:
blinder.tritanopia("#42dead");
blinder.tritanopia("#42dead", false);
blinder.tritanopia("#42dead", true);
blinder.achromatomaly(colorString, returnRgb)
Part of the "Monochromat" family of color blindness. The viewer sees the absence of most color.
Examples:
blinder.achromatomaly("#42dead");
blinder.achromatomaly("#42dead", false);
blinder.achromatomaly("#42dead", true);
blinder.achromatopsia(colorString, returnRgb)
Part of the "Monochromat" family of color blindness. The viewer sees no color at all.
Examples:
blinder.achromatopsia("#42dead");
blinder.achromatopsia("#42dead", false);
blinder.achromatopsia("#42dead", true);
Links
Release History
v0.1.0 - Released June 21, 2014
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.