Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

d3-color-difference

danburzo1.6kBSD-3-Clause0.1.3

See this Observable notebook for a demonstration.

d3, d3-color, color, color-difference, cie76, cie94, ciede2000, cmc

readme

d3-color-difference

See this Observable notebook for a demonstration.

Installing

$ npm install d3-color-difference

API Reference

Euclidean Distances

# d3.differenceEuclideanRGB(a_, _b) <>

Computes the Euclidean distance between the colors a_ and _b in the RGB color space.

# d3.differenceEuclideanLab(a_, _b) <>

Computes the Euclidean distance between the colors a_ and _b in the Lab color space.

# d3.differenceEuclideanHcl(a_, _b) <>

Computes the Euclidean distance between the colors a_ and _b in the HCL color space.

# d3.differenceEuclideanHsl(a_, _b) <>

Computes the Euclidean distance between the colors a_ and _b in the HSL color space.

# d3.differenceEuclideanCubehelix(a_, _b) <>

Computes the Euclidean distance between the colors a_ and _b in the Cubehelix color space.

CIE Delta-E

# d3.differenceCie76(a_, _b) <>

Computes the CIE76 ΔE*ab color difference between the colors a_ and _b. The computation is done in the Lab color space and it is analogous to differenceEuclideanLab.

# d3.differenceCie94(a_, _b) <>

Computes the CIE94 ΔE*94 color difference between the colors a_ and _b. The computation is done in the Lab color space, with the default weights kL = 1, K1 = 0.045, and K2 = 0.015.

# d3.differenceCie94Weighted(kL, K1, K2) <>

Returns a CIE94 difference function with custom weighting parameters.

# d3.differenceCiede2000(a_, _b) <>

Computes the CIEDE2000 ΔE*00 color difference between the colors a_ and _b as implemented by G. Sharma. The computation is done in the Lab color space, with the default weights kL = kC = kH = 1.

# d3.differenceCiede2000Weighted(kL, kC, kH) <>

Returns a CIEDE2000 difference function with custom weighting parameters.

# d3.differenceCmc(a_, _b) <>

Computes the CMC l:c (1984) ΔE*CMC color difference between the colors a_ and _b. The computation is done in the Lab color space with the default weights l = c = 1.

Note: ΔE*CMC is not considered a metric since it's not symmetrical, i.e. the distance from a_ to _b is not always equal to the distance from b_ to _a.

# d3.differenceCmcWeighted(l_, _c) <>

Returns a CMC l:c (1984) difference function with custom weighting parameters.

# d3.differenceDin99o(a_, _b) <>

Computes the DIN99o ΔE*99o color difference between the colors a_ and _b. The computation is done in the DIN99o color space with the default weights kCH = kE = 1.

# d3.differenceDin99oWeighted(kCH, kE) <>

Returns a DIN99o difference function with custom weighting parameters.

Opacity

# d3.differenceWithOpacity(differenceFunction, a_, _b) <>

The difference functions don't take the colors' alpha channel into account when computing distances. This method allows you to factor the colors' opacities into the distance.

changelog

0.1.3

Addeed the DIN99o Delta-E color difference formula.