Skip to content

apcaContrastLc

apcaContrastLc(fg, bg): number

Defined in: packages/math-color/src/encoding/rgb8/accessibility/apca-contrast-lc.ts:25

Computes the APCA (Accessible Perceptual Contrast Algorithm) Lightness Contrast (Lc) between a foreground and a background color.

Implements APCA-W3 version 0.0.98G-4g as defined in the W3C CSS Color 5 specification. https://www.w3.org/TR/css-color-5/#colorcontrast https://github.com/Myndex/SAPC-APCA

The result is Lc, a signed value roughly in the range [-108, 106]: - Positive Lc: darker text on lighter background (normal polarity). - Negative Lc: lighter text on darker background (reverse polarity). - Values between -10 and 10 are clamped to 0 (insufficient contrast to measure).

Approximate usage thresholds (absolute Lc): - ≥ 75: fluent body text - ≥ 60: large or bold text - ≥ 45: large text or non-text UI elements - ≥ 15: incidental text (disabled, placeholder)

Rgb8

The foreground (text) color with components in the range [0, 255].

Rgb8

The background color with components in the range [0, 255].

number

The Lc value.