calculateContrastRatio

Calculates the contrast ratio between two colors.

The contrast ratio is a measure of legibility, comparing the lightness of two colors. It is used widely in the industry due to its compliance with WCAG (Web Content Accessibility Guidelines). Colors are represented in the XYZ color space, where Y represents lightness (relative luminance). The contrast ratio is calculated using the formula: ratio = (lighter Y + 5) / (darker Y + 5).

WCAG 2.0 requires a minimum contrast ratio of 4.5:1 for normal text and 3:1 for large text. WCAG 2.1 requires a minimum of 3:1 for graphics and UI components. WCAG Level AAA requires 7:1 for normal text and 4.5:1 for large text.

Receiver

The first Color to compare.

Return

The contrast ratio between the two colors.

Parameters

other

The second Color to compare.