contrastRatio
Contrast ratio is a measure of legibility, its used to compare the lightness of two colors. This method is used commonly in industry due to its use by WCAG.
To compare lightness, the colors are expressed in the XYZ color space, where Y is lightness, also known as relative luminance.
The equation is ratio = lighter Y + 5 / darker Y + 5.
WCAG 2.0 level AA requires a contrast ratio of at least 4.5:1 for normal text and 3:1 for large text. WCAG 2.1 requires a contrast ratio of at least 3:1 for graphics and user interface components (such as form input borders). WCAG Level AAA requires a contrast ratio of at least 7:1 for normal text and 4.5:1 for large text.
Receiver
The first Color to compare.
Return
Contrast ratio of two colors.
Parameters
other
The second Color to compare.