Skip to main content

ensure_minimum_contrast

Function ensure_minimum_contrast 

Source
pub fn ensure_minimum_contrast(
    foreground: Hsla,
    background: Hsla,
    minimum_apca_contrast: f32,
) -> Hsla
Expand description

Adjusts the foreground color to meet the minimum APCA contrast against the background. The minimum_apca_contrast should be an absolute value (e.g., 75 for Lc 75).

This implementation gradually adjusts the lightness while preserving the hue and saturation as much as possible, only falling back to black/white when necessary.