The Color Blind API can simulate different types of color blindness.
toAchromatomaly
The toAchromatomaly method simulates achromatomaly for a color.
Syntax
toAchromatomaly(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating achromatomaly.
Examples
toAchromatomaly('#42D37A') // Expected output: '#73b58d'
toAchromatomaly({ r: 45, g: 75, b: 200 }) // Expected output: { r: 64, g: 77, b: 134 }
toAchromatopsia
The toAchromatopsia method simulates achromatopsia for a color.
Syntax
toAchromatopsia(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating achromatopsia.
Examples
toAchromatopsia('#42D37A') // Expected output: '#858585'
toAchromatopsia({ r: 45, g: 75, b: 200 }) // Expected output: { r: 107, g: 107, b: 107 }
toDeuteranomaly
The toDeuteranomaly method simulates deuteranomaly for a color.
Syntax
toDeuteranomaly(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating deuteranomaly.
Examples
toDeuteranomaly('#42D37A') // Expected output: '#5fad86'
toDeuteranomaly({ r: 45, g: 75, b: 200 }) // Expected output: { r: 51, g: 67, b: 182 }
toDeuteranopia
The toDeuteranopia method simulates deuteranopia for a color.
Syntax
toDeuteranopia(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating deuteranopia.
Examples
toDeuteranopia('#42D37A') // Expected output: '#786d94'
toDeuteranopia({ r: 45, g: 75, b: 200 }) // Expected output: { r: 54, g: 54, b: 162 }
toProtanomaly
The toProtanomaly method simulates protanomaly for a color.
Syntax
toProtanomaly(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating protanomaly.
Examples
toProtanomaly('#42D37A') // Expected output: '#5ca285'
toProtanomaly({ r: 45, g: 75, b: 200 }) // Expected output: { r: 50, g: 65, b: 184 }
toProtanopia
The toProtanopia method simulates protanopia for a color.
Syntax
toProtanopia(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating protanopia.
Examples
toProtanopia('#42D37A') // Expected output: '#808290'
toProtanopia({ r: 45, g: 75, b: 200 }) // Expected output: { r: 57, g: 58, b: 170 }
toTritanomaly
The toTritanomaly method simulates tritanomaly for a color.
Syntax
toTritanomaly(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating tritanomaly.
Examples
toTritanomaly('#42D37A') // Expected output: '#47bb8a'
toTritanomaly({ r: 45, g: 75, b: 200 }) // Expected output: { r: 46, g: 108, b: 177 }
toTritanopia
The toTritanopia method simulates tritanopia for a color.
Syntax
toTritanopia(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
Return value
A color of type BaseColor simulating tritanopia.
Examples
toTritanopia('#42D37A') // Expected output: '#49a0ac'
toTritanopia({ r: 45, g: 75, b: 200 }) // Expected output: { r: 47, g: 145, b: 129 }
toColorBlind
The toColorBlind method simulates any color blindness type for a color.
Syntax
toColorBlind(color)
Parameters
color: A color of type BaseColor, The method will identify the correct format to operate.
colorBlindness: A string of type ColorBlindness.
Return value
A color of type BaseColor simulating the selected type of color blindness.
Examples
toColorBlind('#f4fa53', 'tritanopia') // Expected output: '#f49bb2'
toColorBlind({ r: 195, g: 144, b: 244 }, 'deuteranopia') // Expected output: { r: 175, g: 179, b: 213 }