Accessibility
Functionsβ
contrast()β
contrast(
a
,b
):number
Gets the contrast between the passed in colors.
Swapping color a
and b
in the parameter list doesn't change the resulting value. The maximum value is 21 (or the contrast between black and white).
Parametersβ
β’ a: ColorToken
= "white"
First color to query. The default is white
.
β’ b: ColorToken
= "black"
The color to compare against. The default is black
.
Returnsβ
number
Exampleβ
import { contrast } from 'huetiful-js'
console.log(contrast("blue", "red"));
// 21
Defined inβ
deficiency()β
deficiency(
color
,options
):ColorToken
Simulates how a color may be perceived by people with color vision deficiency.
To avoid writing the long types, the expected parameters for the kind
of blindness are simply the colors that are hard to perceive for the type of color blindness:
-
'monochromacy'
- An inability to see color, only perceiving shades of gray. Thekind
ismono
. -
'tritanopia'
- An inability to distinguish the color 'blue'. Thekind
is'blue'
. -
'deuteranopia'
- An inability to distinguish the color 'green'.. Thekind
is'green'
. -
'protanopia'
- An inability to distinguish the color 'red'. Thekind
is'red'
.
Parametersβ
β’ color: ColorToken
= "cyan"
The color to return its simulated variant. The default is cyan
.
β’ options: DeficiencyOptions
= ...
The optional overrides for tweaking the final output.
Returnsβ
Exampleβ
import { deficiency } from 'huetiful-js'
// Here we are simulating color blindness of tritanomaly or we can't see 'blue'.
// We are passing in our color as an array of channel values in the mode "rgb". The severity is set to 0.5
console.log(deficiency(['rgb', 230, 100, 50, 0.5],{ kind:'blue', severity:0.5 }))
// '#dd663680'