Measure APCA contrast

Interpret signed APCA lightness contrast without discarding foreground-background polarity or inventing a universal pass threshold.

Use APCA when the workflow explicitly requires polarity-aware lightness contrast. Keep foreground first and background second, retain the sign, and interpret the magnitude with the typography policy used by that workflow.

Preserve polarity

Unlike a WCAG ratio, an APCA Lc value changes sign when foreground and background are swapped. The sign records polarity; it is not an error or a pass/fail result.

use PhpColor\Color\Color;
use PhpColor\Color\Contrast\ApcaContrast;

$normal = ApcaContrast::lc(
    Color::parse('#1e293b'),
    Color::parse('#f8fafc'),
);

$reverse = ApcaContrast::lc(
    Color::parse('#f8fafc'),
    Color::parse('#1e293b'),
);

printf("%.3f\n%.3f\n", $normal, $reverse);
use PhpColor\Color\Color; use PhpColor\Color\Contrast\ApcaContrast; $normal = ApcaContrast::lc( Color::parse('#1e293b'), Color::parse('#f8fafc'), ); $reverse = ApcaContrast::lc( Color::parse('#f8fafc'), Color::parse('#1e293b'), ); printf("%.3f\n%.3f\n", $normal, $reverse);

The output is:

98.248
-100.788
98.248 -100.788

The magnitudes are not identical because APCA models the two polarities differently. Taking abs() too early removes information needed for interpretation.

Keep measurement and policy separate

PHPColor returns a positive value for dark foreground on a lighter background, a negative value for light foreground on a darker background, and 0.0 for identical or nearly indistinguishable luminance.

PHPColor does not expose APCA conformance thresholds, typography lookup tables, a solver, or a pass/fail method. Keep font size, weight, role, and the chosen APCA policy beside the measured Lc value.

Do not substitute APCA and WCAG numbers for one another. Use Measure WCAG contrast when a WCAG 2.x ratio is the requirement. Continue with Measure APCA contrast or ApcaContrast for the exact calculator contract.