Check color distinguishability

Use simulated color distance as a screening signal while preserving redundant cues for every critical distinction.

Use areDistinguishable() to flag pairs that may converge under one simulated vision profile. Do not use its boolean as a complete accessibility verdict.

Understand what the threshold measures

The method simulates both colors, measures Euclidean distance between their normalized sRGB channels, and compares the result with a threshold:

use PhpColor\Color\Color;
use PhpColor\Color\Vision\ColorVisionSimulator;
use PhpColor\Color\Vision\VisionProfile;

$simulator = new ColorVisionSimulator();

$distinct = $simulator->areDistinguishable(
    Color::parse('#ef4444'),
    Color::parse('#22c55e'),
    VisionProfile::Deuteranopia,
    0.06,
);
use PhpColor\Color\Color; use PhpColor\Color\Vision\ColorVisionSimulator; use PhpColor\Color\Vision\VisionProfile; $simulator = new ColorVisionSimulator(); $distinct = $simulator->areDistinguishable( Color::parse('#ef4444'), Color::parse('#22c55e'), VisionProfile::Deuteranopia, 0.06, );

The default threshold is 0.06. This method does not use CIEDE2000, Delta E 94, or CMC. Its threshold belongs to the simulator’s normalized sRGB-distance calculation and must not be compared directly with Delta E values.

Treat the boolean as a screening signal. Test your actual palette, component size, adjacency, labels, and state design. For critical distinctions, provide redundant cues such as text, icons, patterns, or shape.

Review a system in layers

  1. simulate the complete palette under the selected profiles;
  2. screen every pair that carries distinct meaning;
  3. inspect the actual component with its labels and geometry;
  4. measure foreground-background contrast separately;
  5. keep redundant cues even when the screening result passes.

A higher threshold is more conservative, but it is still expressed in this simulator's sRGB-distance model. Establish it with representative UI examples rather than borrowing a Delta E tolerance.

Continue with Simulate color vision deficiencies, Simulate a palette for deuteranopia, or Test color distinguishability.