Test color distinguishability
Find pairs that become too similar under a selected color vision profile before hue carries meaning by itself.
Original
danger
#dc2626
info
#2563eb
result
distinct
Mono
danger
#5c5c5c
info
#606060
result
not distinct
threshold: 0.06
monochromacy: false
One semantic pair collapses under monochromacy
The original red and blue are separated. Their simulated grays, #5c5c5c and #606060, fall below the helper's default threshold.
Test the pair under one named profile
areDistinguishable() simulates both colors, calculates their Euclidean sRGB distance, and compares it with the supplied threshold.
<?php
use PhpColor\Color\Color;
use PhpColor\Color\Vision\ColorVisionSimulator;
use PhpColor\Color\Vision\VisionProfile;
$simulator = ColorVisionSimulator::create(
VisionProfile::Monochromacy,
);
$distinct = $simulator->areDistinguishable(
Color::parse('#dc2626'),
Color::parse('#2563eb'),
);
// false
use PhpColor\Color\Color;
use PhpColor\Color\Vision\ColorVisionSimulator;
use PhpColor\Color\Vision\VisionProfile;
$simulator = ColorVisionSimulator::create(
VisionProfile::Monochromacy,
);
$distinct = $simulator->areDistinguishable(
Color::parse('#dc2626'),
Color::parse('#2563eb'),
);
// false
The threshold is a project heuristic
The helper's distance is not Delta E, WCAG, APCA, or a clinical measure. Use it to flag relationships for design review, then retain labels, shapes, patterns, and contrast in the finished interface.
SimulationTransforms both sRGB colors first.
DistanceEuclidean separation in sRGB.
DefaultA threshold of 0.06.
DecisionA review signal, not an accessibility verdict.