https://doi.org/10.1002/col.22451 describes a color-difference method that might work better than CIE 76 for large distances while still being quite easy to implement. It applies to all Euclidean color spaces with a lightness and two chroma systems, although it's originally defined for LAB only. An implementation would be:
// This generic implementation assumes that element 0 is lightness and the other 2 are chroma.
function dHyAB(color1, color2, mode='lab') {
[lab1, lab2] = [color1, color2].map(e => e[mode]())
[dl, da, db] = lab1.map((e, i) => e - lab2[i])
return Math.sqrt(da ** 2 + db ** 2) + Math.abs(dl)
}
https://doi.org/10.1002/col.22451 describes a color-difference method that might work better than CIE 76 for large distances while still being quite easy to implement. It applies to all Euclidean color spaces with a lightness and two chroma systems, although it's originally defined for LAB only. An implementation would be: