npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-color-difference

v0.1.3

Published

See this [Observable notebook](https://beta.observablehq.com/@danburzo/color-difference-formulas-with-d3-color-difference) for a demonstration.

Downloads

2,364

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.