Color utilities
Check a color before you branch on it. You can read opacity, test equality, check the gamut or find out whether the color is light or dark.
Example
import { colore } from 'colore-js';
const blue = colore('#2563eb80');
console.log(blue.alpha().toFixed(3)); // '0.502'
console.log(blue.format()); // 'hex-alpha'
console.log(colore('#111827').isDark()); // true
Syntax
Throws
A ColorError if a gamut name is unknown, the comparison color is invalid, or the tolerance is negative or non-finite.
Check exact equality before exporting
import { colore } from 'colore-js';
const black = colore('#000');
console.log(black.equals('#191919')); // true
console.log(black.equals('#191919', 0)); // false
Set the tolerance to 0 to compare exact channel values. For similarity by appearance, choose deltaE or deltaEOK. For readable text, measure contrast against its background.