Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/matthewmueller/hex-to-color-name
Tiny module to map hex colors to color names of your choice.
https://github.com/matthewmueller/hex-to-color-name
Last synced: about 1 month ago
JSON representation
Tiny module to map hex colors to color names of your choice.
- Host: GitHub
- URL: https://github.com/matthewmueller/hex-to-color-name
- Owner: matthewmueller
- Created: 2015-04-10T07:39:56.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-01T04:20:06.000Z (about 9 years ago)
- Last Synced: 2024-05-02T00:03:56.920Z (7 months ago)
- Language: JavaScript
- Homepage:
- Size: 120 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
README
# Hex to Color Name
Tiny module to map hex colors to names of your choice. Good for coercing arbitrary hex colors to a name.
## Example
```js
colors('#ffffff') // => "white"
colors('#ff0ff0') // => "pink"
colors('#0000f0') // => "blue"
```## Installation
```
npm install hex-to-color-name
```## API
### `colors(hex, color_map)`
Select the closest color to `hex` in the `color_map`.
The default `color_map` is:
```
{
"white": "FFFFFF",
"black": "000000",
"red": "FF0000",
"green": "00FF00",
"blue": "0000FF",
"pink": "FF00FF",
"yellow": "FFFF00",
"teal": "00FFFF"
}
```Submit a PR to add more (basic) colors.
## License
MIT