ApcaContrast
APCA (Advanced Perceptual Contrast Algorithm) Lc calculation.
Implements the canonical APCA 0.0.98G "G-4g" base algorithm (SAPC-8, simple
version), ported from the W3-licensed reference implementation at
https://github.com/Myndex/apca-w3 (Beta 0.1.9, 2022-07-03 revision).
Notes:
- Returns Lc (contrast) where sign indicates polarity:
+ Positive: dark text on light background (preferred polarity)
- Negative: light text on dark background (reverse polarity)
- Values roughly in the range [-108, +108].
- Alpha is ignored, matching ColorContrast's WCAG calculation.
Methods
lc
static
public static function lc(ColorInterface $fg, ColorInterface $bg): float
Compute APCA Lc for two colors (foreground text over background).
Parameters
| Name | Type | Default |
|---|---|---|
$fg |
ColorInterface | - |
$bg |
ColorInterface | - |