color-name-list
Advanced tools
Comparing version 9.33.0 to 10.0.0
{ | ||
"name": "color-name-list", | ||
"version": "9.33.0", | ||
"version": "10.0.0", | ||
"description": "long list of color names", | ||
@@ -13,3 +13,2 @@ "main": "dist/colornames.json", | ||
"build": "npm run clean-dist-folder && node scripts/build.js", | ||
"start": "node scripts/server.js", | ||
"semantic-release": "semantic-release" | ||
@@ -16,0 +15,0 @@ }, |
101
README.md
@@ -9,5 +9,5 @@ <img align="left" height="119" width="119" src="https://meodai.github.io/color-names/logo/cockatoo-fill.svg"> | ||
[![npm](https://img.shields.io/npm/dt/color-name-list.svg)](https://www.npmjs.com/package/color-name-list) | ||
[![name count](https://img.shields.io/badge/__29978__-names-orange.svg)](https://github.com/meodai/color-names/blob/master/src/colornames.csv) | ||
[![name count](https://img.shields.io/badge/__30000__-names-orange.svg)](https://github.com/meodai/color-names/blob/master/src/colornames.csv) | ||
A handpicked list of __29978__ unique color names from | ||
A handpicked list of __30000__ unique color names from | ||
[various sources](#sources-) and thousands of curated user submissions. | ||
@@ -57,3 +57,3 @@ | ||
## Color Count: __29978__ ๐ | ||
## Color Count: __30000__ ๐ | ||
@@ -109,85 +109,13 @@ ~__0.18%__ of the RGB color space | ||
```url | ||
https://api.color.pizza/v1/{{hexvalue without the #}},{{more comma separated values}} | ||
``` | ||
To make it easier to access the names, we offer a free and public Rest API that | ||
allows you to access all the color names and names from other publicly available | ||
name lists. You can find the full API code and documentation | ||
[in this repository](https://github.com/meodai/color-name-api). | ||
or | ||
#### API Exaple Call Usage | ||
```url | ||
https://api.color.pizza/v1/?values={{hexvalue without the #}},{{more comma separated values}} | ||
https://api.color.pizza/v1/?values=00f,f00,f00&list=bestOf | ||
``` | ||
#### Single Color | ||
`curl` [https://api.color.pizza/v1/212121](https://api.color.pizza/v1/212121) | ||
```javascript | ||
{ | ||
"colors": [{ | ||
"name": "Lead", | ||
"hex": "#212121", | ||
"rgb": {"r": 33, "g": 33, "b": 33}, | ||
"distance": 0, // its an exact match | ||
"luminance": 22.062320231562225, | ||
"requestedHex": "#212121", | ||
}] | ||
} | ||
``` | ||
#### Multiple Colors | ||
`curl` [https://api.color.pizza/v1/212121,060606,ff0012,550055,123456](https://api.color.pizza/v1/212121,060606,ff0012,550055,123456) | ||
or | ||
`curl` [https://api.color.pizza/v1/?values=212121,060606,ff0012,550055,123456](https://api.color.pizza/v1/?values=212121,060606,ff0012,550055,123456) | ||
#### All Named Colors | ||
`curl` [https://api.color.pizza/v1/](https://api.color.pizza/v1/) | ||
In this case colors is not an `object` but an `array` of `objects` sorted by color-name | ||
#### Unique Color-Names | ||
by adding `?noduplicates=true` every returned name will be unique. | ||
The closest color, that was not returned previously will be returned: | ||
`curl` [https://api.color.pizza/v1/?values=212121,212121&noduplicates=true](https://api.color.pizza/v1/?values=212121,212121&noduplicates=true) | ||
```javascript | ||
{ | ||
"colors": [{ | ||
"name": "Lead", | ||
"hex": "#212121", | ||
"rgb": { "r": 33, "g": 33, "b": 33 }, | ||
"luminance": 22.062320231562225 | ||
},{ | ||
"name": "Abaddon Black", | ||
"hex": "#231f20", | ||
"rgb": { "r": 35, "g": 31, "b": 32 }, | ||
"luminance": 21.30621829419759 | ||
}] | ||
} | ||
``` | ||
#### Search for colors by name | ||
```url | ||
https://api.color.pizza/v1/names/{{query}} | ||
``` | ||
or | ||
```url | ||
https://api.color.pizza/v1/names/?name={{query}} | ||
``` | ||
Returns an `array` of color `objects` which match the given query, sorted by color-name: | ||
`curl` [https://api.color.pizza/v1/names/red](https://api.color.pizza/v1/names/red) | ||
#### Good Color-Names | ||
Not all color-names are created equal; add [`?goodnamesonly=true`](https://api.color.pizza/v1/?values=212121,060606,ff0012,550055,123456&goodnamesonly=true) | ||
to your request URL to get a handpicked subset of names that were rated as good | ||
by humans. (Colors that are liked a lot on [twitter](https://twitter.com/color_parrot) | ||
and some of the team favourites). | ||
#### API Disclaimer | ||
@@ -199,3 +127,3 @@ | ||
Feel free to deploy it yourself, it is very easy to host/deploy on heroku and | ||
has no dependencies [server.js](https://github.com/meodai/color-names/blob/master/scripts/server.js) | ||
has no dependencies [Color-Name-API](https://github.com/meodai/color-name-api) | ||
@@ -311,2 +239,3 @@ ### Usage JS โจ | ||
- [Dmitry Iv.] 10USD/month | ||
- [colorkit.co] 10USD/month | ||
@@ -363,3 +292,8 @@ #### Bronze | ||
In an effort to create a more inclusive and respectful environment, we strive to remove all offensive and racist names, as well as protected brand names, from our list. While we do our best to screen out such names, some may still slip through. If you come across any such names, please [let us know](https://github.com/meodai/color-names/issues/new?title=Bad%20color%20name) so that we can remove them promptly. | ||
In an effort to create a more inclusive and respectful environment, we strive to | ||
remove all offensive and racist names, as well as protected brand names, | ||
from our list. While we do our best to screen out such names, some may still | ||
slip through. If you come across any such names, please | ||
[let us know](https://github.com/meodai/color-names/issues/new?title=Bad%20color%20name) | ||
so that we can remove them promptly. | ||
@@ -415,2 +349,3 @@ ## Latest Color Names ๐ | ||
[neverything]: https://neverything.me/ | ||
[colorkit.co]: https://colorkit.co/ | ||
[Myriam Aerne]: https://fynoeggeli.ch/ | ||
@@ -417,0 +352,0 @@ [nachtfunke]: https://helloyes.dev |
@@ -1,3 +0,1 @@ | ||
const RGB_HEX = /^#?(?:([\da-f]{3})[\da-f]?|([\da-f]{6})(?:[\da-f]{2})?)$/i; | ||
module.exports = { | ||
@@ -91,110 +89,2 @@ /** | ||
}, | ||
// return HSP luminance http://alienryderflex.com/hsp.html | ||
luminance: (rgb) => (Math.sqrt( | ||
Math.pow(0.299 * rgb.r, 2) + | ||
Math.pow(0.587 * rgb.g, 2) + | ||
Math.pow(0.114 * rgb.b, 2) | ||
)), | ||
/** | ||
* disassembles a HEX color to its RGB components | ||
* https: //gist.github.com/comficker/871d378c535854c1c460f7867a191a5a#gistcomment-2615849 | ||
* @param {string} hexSrt hex color representatin | ||
* @return {object} {r,g,b} | ||
*/ | ||
hexToRgb: (hexSrt) => { | ||
const [, short, long] = String(hexSrt).match(RGB_HEX) || []; | ||
if (long) { | ||
const value = Number.parseInt(long, 16); | ||
return { | ||
r: value >> 16, | ||
g: value >> 8 & 0xFF, | ||
b: value & 0xFF, | ||
}; | ||
} else if (short) { | ||
const rgbArray = Array.from(short, | ||
(s) => Number.parseInt(s, 16) | ||
).map((n) => (n << 4) | n); | ||
return { | ||
r: rgbArray[0], | ||
g: rgbArray[1], | ||
b: rgbArray[2], | ||
}; | ||
} | ||
}, | ||
/** | ||
* Converts an RGB color value to HSL. Conversion formula | ||
* adapted from http://en.wikipedia.org/wiki/HSL_color_space. | ||
* Assumes r, g, and b are contained in the set [0, 255] and | ||
* returns h, s, and l in the set [0, 1]. | ||
* | ||
* @param {Number} r The red color value | ||
* @param {Number} g The green color value | ||
* @param {Number} b The blue color value | ||
* @return {Object} The HSL representation | ||
*/ | ||
rgbToHsl: (r, g, b) => { | ||
r = r / 255; | ||
g = g / 255; | ||
b = b / 255; | ||
const min = Math.min(r, g, b); | ||
const max = Math.max(r, g, b); | ||
const delta = max - min; | ||
let h; | ||
let s; | ||
let l; | ||
if (max === min) { | ||
h = 0; | ||
} else if (r === max) { | ||
h = (g - b) / delta; | ||
} else if (g === max) { | ||
h = 2 + (b - r) / delta; | ||
} else if (b === max) { | ||
h = 4 + (r - g) / delta; | ||
} | ||
h = Math.min(h * 60, 360); | ||
if (h < 0) { | ||
h += 360; | ||
} | ||
l = (min + max) / 2; | ||
if (max === min) { | ||
s = 0; | ||
} else if (l <= 0.5) { | ||
s = delta / (max + min); | ||
} else { | ||
s = delta / (2 - max - min); | ||
} | ||
s *= 100; | ||
l *= 100; | ||
return { | ||
h, | ||
s, | ||
l, | ||
}; | ||
}, | ||
/** | ||
* calculates the distabce between two RGB colors | ||
* @param {object} rgb1 object containing r,g and b properties | ||
* @param {object} rgb2 object containing r,g and b properties | ||
* @return {int} distance | ||
*/ | ||
distance: (rgb1, rgb2) => ( | ||
Math.sqrt( | ||
Math.pow(rgb1.r - rgb2.r, 2) + | ||
Math.pow(rgb1.g - rgb2.g, 2) + | ||
Math.pow(rgb1.b - rgb2.b, 2) | ||
) | ||
), | ||
}; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
13877382
5
1
50
16296
376