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

color-namer

v1.4.0

Published

Give me a color and I'll name it.

Downloads

36,424

Readme

Color Namer Build Status

Give me a color and I'll name it.

Color Namer is an npm package for use in Node.js or the browser that calculates color distance using the Delta-E color difference technique. Given a color in Hexadecimal RGB, RGBA, HSL, or HSV format, it converts the color to the Lab* color space, then calculates the color's Euclidean distance from a set of colors with known names.

Mike Bostock of D3 fame explains it well:

Lab and HCL color spaces are special in that the perceived difference between two colors is proportional to their Euclidean distance in color space. This special property, called perceptual uniformity, makes them ideal for accurate visual encoding of data. In contrast, the more familiar RGB and HSL color spaces distort data when used for visualization.

Lists

The color names are derived from several lists:

Installation

npm install color-namer --save

Usage

Require the module:

var namer = require('color-namer')
var names = namer("#FF0000")

From the above code, names will have a key for each list:

names.roygbiv
names.basic
names.html
names.x11
names.pantone
names.ntc

Each list is an array of colors, sorted by their perceptual similarity to the given color:

[
  { name: 'red',
    hex: '#FF0000',
    distance: 0
  },{
    name: 'orangered',
    hex: '#FF4500',
    distance: 13.170205025755513
  },{
    name: 'tomato',
    hex: '#FF6347',
    distance: 31.733444038510665
  },{
    name: 'crimson',
    hex: '#DC143C',
    distance: 35.38084849496472
  },{
    name: 'firebrick',
    hex: '#B22222',
    distance: 40.71076805218006
  },{
    name: 'coral',
    hex: '#FF7F50',
    distance: 42.340752375722616
  },{
    name: 'chocolate',
    hex: '#D2691E',
    distance: 44.378454180212145
  }
]

Other input format work too like HSL, RGB, and RGBA:

name("hsl(50,100%,50%)")
name("rgb(255,0,0)")
name("rgba(255,0,0,1)")

Options

options.pick

This option allows us to derive names from the dedicated lists for faster computation.

var names = namer(color, { pick: ['basic', 'x11'] })
// output: { basic: [...], x11: [...] }

options.omit

The opposite of options.pick.

var names = namer(color, { omit: ['pantone', 'roygbiv'] })
// output: { basic: [...], html: [...], x11: [...], ntc: [...] }

options.distance

If 'deltaE', use the Delta-E distance function, otherwise uses default distance function.

var names = namer(color, { pick: ['basic'], distance: 'deltaE' });
// output: { basic: [...] }

Tests

npm install
npm test

License

MIT