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.
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.
The color names are derived from several lists:
npm install color-namer --save
Require the module:
var namer =var names =
From the above code,
names will have a key for each list:
Each list is an array of colors, sorted by their perceptual similarity to the given color:
name: 'red'hex: '#FF0000'distance: 0name: 'orangered'hex: '#FF4500'distance: 13170205025755513name: 'tomato'hex: '#FF6347'distance: 31733444038510665name: 'crimson'hex: '#DC143C'distance: 3538084849496472name: 'firebrick'hex: '#B22222'distance: 4071076805218006name: 'coral'hex: '#FF7F50'distance: 42340752375722616name: 'chocolate'hex: '#D2691E'distance: 44378454180212145
Other input format work too like HSL, RGB, and RGBA:
npm installnpm test