Color-blindness simulation helpers.
simulate/2 applies the standard dichromacy simulation matrices from
Machado, Oliveira and Fernandes ("A Physiologically-based Model for
Simulation of Color Vision Deficiency", 2009) to an RGB color.
Supported deficiencies:
:protanopia- missing L cone (red-blind):deuteranopia- missing M cone (green-blind):tritanopia- missing S cone (blue-blind)
The simulation is useful to check that palette choices remain distinguishable for color-blind users.
Examples
iex> Pote.Accessibility.simulate({255, 0, 0}, :protanopia)
{39, 29, 0}
Summary
Functions
Returns true when two colors remain distinguishable (WCAG contrast
ratio above threshold, default 3.0 — large-text AA) after
simulating deficiency.
Simulates how a person with deficiency perceives the given RGB
color, returning the simulated RGB tuple.
Types
Functions
@spec distinguishable?(Pote.rgb(), Pote.rgb(), deficiency(), float()) :: boolean()
Returns true when two colors remain distinguishable (WCAG contrast
ratio above threshold, default 3.0 — large-text AA) after
simulating deficiency.
Examples
iex> Pote.Accessibility.distinguishable?({255, 0, 0}, {0, 255, 0}, :protanopia)
true
@spec simulate(Pote.rgb(), deficiency()) :: Pote.rgb()
Simulates how a person with deficiency perceives the given RGB
color, returning the simulated RGB tuple.
Examples
iex> Pote.Accessibility.simulate({255, 0, 0}, :protanopia)
{39, 29, 0}
iex> Pote.Accessibility.simulate({0, 255, 0}, :deuteranopia)
{219, 171, 11}