Socket
Socket
Sign inDemoInstall

color-to-name

Package Overview
Dependencies
9
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    color-to-name

A command line tool which helps to map a hex color code to a color name, based on Zeplin's color palette dataset


Version published
Maintainers
1
Install size
515 kB
Created

Readme

Source

Color To Name

Build Status NPM version

A command line tool which helps to map a hex color code to a color name, based on Zeplin's color palette dataset

Please note that the color preview may not be as accurate as the real color. It depends if your terminal supports 24-bit true color. Please refer to: https://github.com/chalk/chalk#256-and-truecolor-color-support

For mac OS, iTerm 3.0+ supports true color by default

Installation

As command line:

npm install -g color-to-name

As project dependency:

npm install color-to-name

Usage

Command line

$ color-to-name --help

  Usage: color-to-name [options]


  Options:

    -V, --version        output the version number
    -a, --all            Print all Zeplin palette colors
    -c, --color [color]  The hex color code
    -h, --help           output usage information
$ 
$ color-to-name -c '#EE4055'
Input Color          -> HEX: #ee4055, RGB: { 238,  64,  85 }, Preview:
Closest Color        -> HEX: #fd4659, RGB: { 253,  70,  89 }, Preview:
Color Name           -> watermelon
$
$ color-to-name -c '#3BAA33'
Input Color          -> HEX: #3baa33, RGB: {  59, 170,  51 }, Preview:
Closest Color        -> HEX: #39ad48, RGB: {  57, 173,  72 }, Preview:
Color Name           -> medium green
$
$ color-to-name -c '#FDB82A'
Input Color          -> HEX: #fdb82a, RGB: { 253, 184,  42 }, Preview:
Closest Color        -> HEX: #ffa62b, RGB: { 255, 166,  43 }, Preview:
Color Name           -> mango

API

You can import the library as your project dependency

const ColorHelper = require('color-to-name');
isValidHexCode(color)

Check if a color hex code is valid

ColorHelper.isValidHexCode('#000000');
// return true

ColorHelper.isValidHexCode('#qwerty');
// return false
hexToRGB(color)

Convert a color hex code to RGB values

ColorHelper.hexToRGB('#123456');
// return { r: 18, g: 52, b: 86 }
getAllColors()

Return the full Zeplin color palette

ColorHelper.getAllColors();
// return {
//   "#000000": "black",
//   "#000133": "very dark blue",
//   .
//   .
//   .
// }
findClosestColor(color)

find the closest color to the input color hex code based on Zeplin's color palette dataset

ColorHelper.findClosestColor('#123456');
// return { color: '#1f3b4d', name: 'dark blue grey' }

To do

  • support more parameters like darken, lighten, hsl, etc

Keywords

FAQs

Last updated on 08 Nov 2019

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc