simulate
simulate previews how a color might appear with color vision deficiency. Compare chart or UI colors under the same simulation to find pairs that may be hard to tell apart.
Example
import { colore } from 'colore-js';
import { simulate } from 'colore-js/fn';
colore('#ef4444').simulate('protanopia').css(); // '#7a7a42'
simulate('#ef4444', 'protanopia'); // '#7a7a42'
Syntax
colore(color).simulate(type: ColorBlindnessType): Color
simulate(color: ColorInput, type: ColorBlindnessType): string
Parameters
Returns
The method returns a Color. The function returns a CSS string, using hex when the result fits sRGB.
Throws
A ColorError for invalid colors or an unsupported simulation type.
Compare red and green chart series
import { simulate } from 'colore-js/fn';
simulate('#ef4444', 'deuteranopia'); // '#9a9a35'
simulate('#10b981', 'deuteranopia'); // '#9b9b85'
These colors move closer in hue under the simulation. Add labels or change the line pattern when distinguishing the two series matters.
Related
- Accessible chart colors to build and check a dashboard palette
- categoricalColors to generate distinct series colors
- audit to check named colors together