Coder Social home page Coder Social logo

colornames's Introduction

colornames

Convert color names to HEX color values.

NPM NPM

Build Status Dependency Status

Installation

Component

$ component install timoxley/colornames

Node/Browserify

$ npm install colornames

Example

var toHex = require('colornames')

VGA color names

toHex('red') // => "#FF0000"
toHex('blue') // => "#0000FF"

CSS color names

toHex('lightsalmon') // => "#FFA07A"
toHex('mediumvioletred') // => "#C71585"

Get meta data about a color

toHex.get('red')
// =>
{
  name: "red",
  css: true,
  value: "#FF0000",
  vga: true
}

Conversion is case-insensitive

toHex('Blue') // => "#0000FF"
toHex('BLUE') // => "#0000FF"
toHex('BlUe') // => "#0000FF"

API

colornames(name)

Get HEX code for a color name, or undefined if unknown.

.get(name)

All known data about color, including whether valid VGA or CSS color name.

.get.vga(name)

HEX code for a color name, only if the color is a valid VGA color name.

.get.css(name)

HEX code for a color name, only if the color is a valid CSS color name.

###.all() Get all color names data.

License

MIT

Complete Color Map

example-color-table-

colornames's People

Contributors

timoxley avatar tongrhj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

colornames's Issues

Gray vs Grey

The name "gray" return hex code but "grey" doesn't. On the otherhand, it's the otherway around for "lightgray" and "lightgrey".

Using the following code for the time being.

toHex(name.replace("gray", "grey")) || toHex(name.replace("grey", "gray"));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.