Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

color-namer

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-namer

Give me a color and I'll name it.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.4K
decreased by-11.78%
Maintainers
1
Weekly downloads
 
Created
Source

Color Namer

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)")

Tests

npm install
npm test

License

MIT

Keywords

FAQs

Package last updated on 09 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc