color-name-list 10.28.1 → 11.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/build.yml +1 -1
- package/.github/workflows/release.yml +1 -1
- package/.husky/pre-commit +1 -0
- package/README.md +43 -6
- package/dist/colornames.bestof.esm.js +1 -1
- package/dist/colornames.bestof.esm.mjs +1 -1
- package/dist/colornames.esm.js +1 -1
- package/dist/colornames.esm.mjs +1 -1
- package/dist/colornames.short.esm.js +1 -1
- package/dist/colornames.short.esm.mjs +1 -1
- package/dist/history.json +1 -1
- package/package.json +24 -10
- package/scripts/build.js +6 -7
- package/scripts/esm.js.tpl +1 -1
- package/scripts/lib.js +82 -77
- package/scripts/tools/history.js +2 -3
- package/src/colornames.csv +22 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
npm test && npm run build
|
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ A handpicked list of __30242__ unique color names from
|
|
|
23
23
|
| <a href="#usage-">Usage</a>
|
|
24
24
|
| <a href="#cdn-">CDN</a>
|
|
25
25
|
| <a href="#api-">Public Rest API</a>
|
|
26
|
-
| <a href="#usage-js-">Usage JS/Java/Kotlin
|
|
26
|
+
| <a href="#usage-js-">Usage JS/Java/Kotlin/C#</a>
|
|
27
27
|
| <a href="#sources-">Name Sources</a>
|
|
28
28
|
| <a href="#latest-color-names-">Latest Color Names</a>
|
|
29
29
|
| <a href="#costs--sponsors">Sponsors</a>
|
|
@@ -135,12 +135,12 @@ consider using the [public rest API](#api-)
|
|
|
135
135
|
#### Exact Color
|
|
136
136
|
|
|
137
137
|
```javascript
|
|
138
|
-
import {
|
|
138
|
+
import { colornames } from 'color-name-list';
|
|
139
139
|
|
|
140
|
-
let someColor =
|
|
140
|
+
let someColor = colornames.find(color => color.hex === '#ffffff');
|
|
141
141
|
console.log(someColor.name); // => white
|
|
142
142
|
|
|
143
|
-
let someNamedColor =
|
|
143
|
+
let someNamedColor = colornames.find(color => color.name === 'Eigengrau')
|
|
144
144
|
console.log(someColor.hex); // => #16161d
|
|
145
145
|
```
|
|
146
146
|
|
|
@@ -151,10 +151,10 @@ Since there are 16777216 possible RGB colors, you might use a library such as
|
|
|
151
151
|
|
|
152
152
|
```js
|
|
153
153
|
import nearestColor from 'nearest-color';
|
|
154
|
-
import {
|
|
154
|
+
import { colornames } from 'color-name-list';
|
|
155
155
|
|
|
156
156
|
// nearestColor need objects {name => hex} as input
|
|
157
|
-
const colors =
|
|
157
|
+
const colors = colornames.reduce((o, { name, hex }) => Object.assign(o, { [name]: hex }), {});
|
|
158
158
|
|
|
159
159
|
const nearest = nearestColor.from(colors);
|
|
160
160
|
|
|
@@ -233,6 +233,43 @@ val fromRGB = colorNames.getName(224, 224, 255) // "Stoic White"
|
|
|
233
233
|
val fromColor = colorNames.getName(Color(255, 219, 240)) // "Silky Pink"
|
|
234
234
|
```
|
|
235
235
|
|
|
236
|
+
### Usage C# ⌨
|
|
237
|
+
|
|
238
|
+
C# usage is maintained through this library:
|
|
239
|
+
[vycdev/ColorNamesSharp](https://github.com/vycdev/ColorNamesSharp)
|
|
240
|
+
Additional info can be found there, but basic usage is outlined below:
|
|
241
|
+
|
|
242
|
+
The library is available as a [nuget package](https://www.nuget.org/packages/ColorNamesSharp)
|
|
243
|
+
|
|
244
|
+
#### Creating the instance
|
|
245
|
+
|
|
246
|
+
```csharp
|
|
247
|
+
ColorNames colorNames = new ColorNamesBuilder()
|
|
248
|
+
.Add("Best Blue", "#3299fe") // Add your own custom colors
|
|
249
|
+
.LoadDefault() // Load the default color list
|
|
250
|
+
.AddFromCsv("path/to/your/colorlist.csv") // Add a custom color list from a csv file
|
|
251
|
+
.Build(); // Get a new ColorNames instance that includes all the colors you've added
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
#### Getting a fitting color name
|
|
255
|
+
|
|
256
|
+
```csharp
|
|
257
|
+
NamedColor customNamedColor = new("Custom Named Color", 50, 153, 254);
|
|
258
|
+
|
|
259
|
+
// You can directly get the name of the color as a string
|
|
260
|
+
string colorNameFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
|
|
261
|
+
string colorNameFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
|
|
262
|
+
string colorNameFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
|
|
263
|
+
|
|
264
|
+
// Or similarly you can get the NamedColor object
|
|
265
|
+
NamedColor namedColorFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
|
|
266
|
+
NamedColor namedColorFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
|
|
267
|
+
NamedColor namedColorFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
|
|
268
|
+
|
|
269
|
+
// Or a random color
|
|
270
|
+
NamedColor randomColor = colorNames.GetRandomNamedColor();
|
|
271
|
+
```
|
|
272
|
+
|
|
236
273
|
## Sources 🗒
|
|
237
274
|
|
|
238
275
|
### Sources: Names 📇
|