Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including misvarvi with all npm packages installed. Try it out:

var misvarvi = require("misvarvi")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

misvarvi v1.0.3

A command-line tool to name colors using CIEDE2000, inspired by cherangi

misvarvi

npm

misvarvi, Estonian for "What color?", is a command-line tool that finds the closest color in color-name-list to the color that was passed in, using the CIEDE2000 color difference algorithm. It was inspired by cherangi but was designed for command-line use, so it emits a well-formed JSON object instead of a debug object, and was also switched to use the CIEDE2000 algorithm instead of the CIE94 algorithm, as it's more accurate.

Installation

npm install --global misvarvi

Usage

Hex colors, CSS HSL, and CSS RGB are accepted, among a few other less useful forms. (See the chromatism docs for all valid forms.)

misvarvi '#AE3440'

It will return a JSON object, which you can then parse using something like jq.

{"delta":1.4980639388194081,"status":4,"hex":"#a73940","name":"Jules"}

The JSON object will always have the following values:

  • delta: the CIEDE2000 DeltaE between the input color and the returned match. null if no match was found.
  • status: see below
  • hex: the exact RGB hex color of the matched color
  • name: the name of the matched color

Status will be one of the following numbers:

  • -1: No match found.
  • 1: Exact match.
  • 2: Difference between match and input is not perceptible by humans.
  • 4: Difference between match and input is perceptible upon close observation.
  • 8: Difference between match and input is perceptible at a glance.
  • 16: Difference between match and input is very apparent, but they are more similar than different.
  • 32: Colors are different, but no better match was found.

They are bitflags because cherangi used bitflags, not because they will ever be returned OR'd together. They could've easily been 0, 1, 2, 3, 4, 5, and 6, but I already have scripts designed for cherangi and didn't want to change them.

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free