Socket
Socket
Sign inDemoInstall

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.


Version published
Maintainers
1
Created
Source

Color Namer

Give me a color and I'll name it.

Color Namer is a node module that calculates color distance using the Delta-E color difference technique. Given a color in some format like RGB, HSL, or HSV, it uses the awesome chroma-js node module to convert the color to the Lab* color space, then calculates the color's Euclidean distance from a set of colors with known names.

Installation

npm install color-namer --save

Usage

Easy peasy:

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

The function returns an array of colors objects, sorted by proximity in the Lab* color space:

[
  { 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
  }
]

Sets

By default, names are chosen from a small set of basic colors.

// These are equivalent:
namer("#FF0000")
namer("#FF0000", 'basic')

To use the HTML color names:

namer("#FF0000", 'html')

Or good ol' ROYGBIV:

namer("#FF0000", 'roygbiv')

Or bring your own name data:

namer("#FF0000", [
  { name: 'black', hex: '#000' },
  { name: 'white', hex: '#FFF' }
])

Tests

npm install
npm test

License

WTFPL

Keywords

FAQs

Package last updated on 20 Jul 2014

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