Function Signature
js
deltaE76(hexA: string, hexB: string): numberParameters
hexA(string): First HEX color string.hexB(string): Second HEX color string.
Return Value
Returns a number representing the perceptual distance (ΔE) between the two colors. Smaller values mean the colors are closer perceptually.
js
deltaE76("#ff6600", "#ff6600");
// 0 (identical colors)
deltaE76("#ff6600", "#ff6622");
// ~2.5 (barely noticeable)
deltaE76("#ff6600", "#00aaff");
// ~60 (very different)Examples
js
// Compare similar oranges
console.log(deltaE76("#ff6600", "#ff6633"));
// ~3 (noticeable but small difference)
// Compare orange and blue
console.log(deltaE76("#ff6600", "#0000ff"));
// ~70 (drastic difference)Implementation Details
- Converts each HEX color to RGB using
hexToRgb. - Transforms RGB to Lab with
rgbToLab. - Computes ΔE as the Euclidean distance between the Lab coordinates:
ΔE = sqrt((ΔL)^2 + (Δa)^2 + (Δb)^2).- This is the simplest form of color difference (CIE76).
Usage Notes
- ΔE < 1: Difference is imperceptible to the human eye.
- ΔE < 2: Only perceptible under close observation.
- ΔE ~ 2–10: Perceptible at a glance.
- ΔE > 10: Colors are clearly different.
- ΔE > 50: Colors appear opposite or unrelated.