deltaE
deltaE measures CIEDE2000 color difference in JavaScript. Use it to compare a target and sample when your workflow specifies ΔE00. You can set your own weights for lightness, chroma and hue.
Example
import { colore } from 'colore-js';
import { deltaE } from 'colore-js/fn';
colore('#7c3aed').deltaE('#7b3ae8').toFixed(3); // '0.647'
deltaE('#7c3aed', '#2563eb').toFixed(3); // '18.267'
Syntax
colore(first).deltaE(second: ColorInput | Color, kL?: number, kC?: number, kH?: number): number
deltaE(first: ColorInput, second: ColorInput, kL?: number, kC?: number, kH?: number): number
Parameters
Returns
Both APIs return a nonnegative ΔE00 number. Alpha is ignored, so colors with identical channels and different opacity have distance zero.
Throws
A ColorError if a color cannot be parsed or a weighting factor is non-finite or at most zero.
Compare samples with lightness weighted down
import { deltaE } from 'colore-js/fn';
deltaE('#7c3aed', '#7b3ae8', 1).toFixed(3); // '0.647'
deltaE('#7c3aed', '#7b3ae8', 2).toFixed(3); // '0.518'
Use the same formula and weights as the specification you are comparing against. Pick a tolerance for your use case and compare the unrounded value in code.
Related
- deltaEOK for distances measured in OKLab
- audit to check color distinction across a palette
- Color precision, rounding and equality to compare individual channels