Function: getContrastRatio()
getContrastRatio(
color1
,color2
):number
Calculates the contrast ratio between two colors according to WCAG 2.0.
The contrast ratio is defined as (L1 + 0.05) / (L2 + 0.05), where L1 is the relative luminance of the lighter of the two colors, and L2 is the relative luminance of the darker of the two colors.
Parameters
Parameter | Type | Description |
---|---|---|
color1 | Color | The first color. |
color2 | Color | The second color. |
Returns
number
A number representing the contrast ratio. The ratio can range from 1 to 21.
Defined in
accessability/components/contrast-ratio.ts:15