color-name-list 13.13.1 β†’ 13.14.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/README.md CHANGED
@@ -27,7 +27,6 @@ A meticulously curated collection of __29985__ unique color names, sourced from
27
27
  | <a href="#usage-">Usage</a>
28
28
  | <a href="#cdn-">CDN</a>
29
29
  | <a href="#api-">Public Rest API</a>
30
- | <a href="#usage-js-">Usage JS/Java/Kotlin/C#</a>
31
30
  | <a href="#sources-">Name Sources</a>
32
31
  | <a href="#latest-color-names-">Latest Color Names</a>
33
32
  | <a href="#costs--sponsors">Sponsors</a>
@@ -91,23 +90,19 @@ color space: [Visualization](https://codepen.io/meodai/full/zdgXJj/)
91
90
 
92
91
  ## Usage πŸ“–
93
92
 
93
+ ### Docs
94
+
95
+ - JS/TS: [docs/usage-js.md](docs/usage-js.md)
96
+ - Java/Kotlin: [docs/usage-java-kotlin.md](docs/usage-java-kotlin.md)
97
+ - C#: [docs/usage-csharp.md](docs/usage-csharp.md)
98
+ - Rust: [docs/usage-rust.md](docs/usage-rust.md)
99
+
94
100
  ### Consuming the list
95
101
 
96
102
  The list is available in [multiple formats](https://app.unpkg.com/color-name-list/files/dist),
97
103
  or you can use the [public REST API](#api-), making it easy to integrate into
98
104
  your project.
99
105
 
100
- ### Node.js Installation πŸ“¦
101
-
102
- __Size Warning (1.14 MB)__: For browser usage,
103
- consider the [public rest API](#api-)
104
-
105
- ```shell
106
- npm install color-name-list --save
107
- ```
108
-
109
- or `yarn add color-name-list`
110
-
111
106
  ### CDN 🌍
112
107
 
113
108
  #### All Names πŸ“š
@@ -133,6 +128,22 @@ or `yarn add color-name-list`
133
128
  / [SCSS](https://unpkg.com/color-name-list/dist/colornames.bestof.scss)
134
129
  / [CSS](https://unpkg.com/color-name-list/dist/colornames.bestof.css)
135
130
 
131
+ ### Usage JS πŸ“¦
132
+
133
+ __Size Warning (1.14 MB)__: For browser usage,
134
+ consider the [public rest API](#api-).
135
+
136
+ Minimal example:
137
+
138
+ ```javascript
139
+ import { colornames } from 'color-name-list';
140
+
141
+ const white = colornames.find((c) => c.hex === '#ffffff');
142
+ console.log(white?.name); // => white
143
+ ```
144
+
145
+ More examples: see `docs/usage-js.md`.
146
+
136
147
  ### API πŸƒ
137
148
 
138
149
  To simplify access, we provide a free and public REST API for all color names
@@ -153,63 +164,6 @@ generates excessive traffic, you may be asked to become a sponsor.
153
164
  You are welcome to self-host the APIβ€”it's easy to deploy on Heroku and relies
154
165
  only on a few dependencies: [Color-Name-API](https://github.com/meodai/color-name-api)
155
166
 
156
- ### Usage JS ⌨
157
-
158
- __Size Warning (1.14 MB)__: For browser usage,
159
- consider the [public rest API](#api-)
160
-
161
- #### Data Shape
162
-
163
- ```ts
164
- type ColorName = { name: string; hex: string };
165
- ```
166
-
167
- #### Exact Color
168
-
169
- ```javascript
170
- import { colornames } from 'color-name-list';
171
-
172
- let someColor = colornames.find((color) => color.hex === '#ffffff');
173
- console.log(someColor.name); // => white
174
-
175
- let someNamedColor = colornames.find((color) => color.name === 'Eigengrau');
176
- console.log(someColor.hex); // => #16161d
177
- ```
178
-
179
- #### CommonJS
180
-
181
- ```js
182
- // Returns the array directly when using CommonJS
183
- const colornames = require('color-name-list');
184
-
185
- const white = colornames.find((c) => c.hex === '#ffffff');
186
- console.log(white.name); // => white
187
- ```
188
-
189
- #### Closest Named Color
190
-
191
- With 16,777,216 possible RGB colors, you may want to use a library such as
192
- [nearest-color] or [ClosestVector] to find the closest named color.
193
-
194
- ```js
195
- import nearestColor from 'nearest-color';
196
- import { colornames } from 'color-name-list';
197
-
198
- // nearestColor expects an object {name => hex}
199
- const colors = colornames.reduce((o, { name, hex }) => Object.assign(o, { [name]: hex }), {});
200
-
201
- const nearest = nearestColor.from(colors);
202
-
203
- // get closest named color
204
- nearest('#f1c1d1'); // => Fairy Tale
205
- ```
206
-
207
- __Note__: For greater visual accuracy, consider using [DeltaE] or the above
208
- approach with [ciecam02] instead of RGB.
209
-
210
- [DeltaE]: https://github.com/zschuessler/DeltaE
211
- [ciecam02]: https://github.com/baskerville/ciecam02
212
-
213
167
  ### Building πŸ”¨
214
168
 
215
169
  ```shell
@@ -218,145 +172,17 @@ npm install && npm run build
218
172
 
219
173
  See [package.json](package.json#L6) for details.
220
174
 
221
- ### Usage Java/Kotlin ⌨
222
-
223
- Java/Kotlin support is provided by:
224
- [UwUAroze/Color-Names](https://github.com/UwUAroze/Color-Names).
225
- See the repository for more, or use the basics below:
226
-
227
- #### Importing - Gradle.kts
228
-
229
- ```kts
230
- repositories {
231
- maven("https://jitpack.io")
232
- }
233
-
234
- dependencies {
235
- implementation("me.aroze:color-names:1.0.4")
236
- }
237
- ```
238
-
239
- #### Importing - Maven
240
-
241
- ```xml
242
- <repository>
243
- <id>jitpack.io</id>
244
- <url>https://jitpack.io</url>
245
- </repository>
246
-
247
- <dependency>
248
- <groupId>me.aroze</groupId>
249
- <artifactId>color-names</artifactId>
250
- <version>1.0.4</version>
251
- </dependency>
252
- ```
253
-
254
- #### Closest named color - Java
255
-
256
- ```java
257
- public ColorNames colorNames = new ColorNameBuilder()
258
- .loadDefaults()
259
- .build();
260
-
261
- String fromHex = colorNames.getName("#facfea"); // "Classic Rose"
262
- String fromRGB = colorNames.getName(224, 224, 255); // "Stoic White"
263
- String fromColor = colorNames.getName(new Color(255, 219, 240)); // "Silky Pink"
264
- ```
265
-
266
- #### Closest named color - Kotlin
267
-
268
- ```kt
269
- val colorNames = ColorNameBuilder()
270
- .loadDefaults()
271
- .build()
272
-
273
- val fromHex = colorNames.getName("#facfea") // "Classic Rose"
274
- val fromRGB = colorNames.getName(224, 224, 255) // "Stoic White"
275
- val fromColor = colorNames.getName(Color(255, 219, 240)) // "Silky Pink"
276
- ```
277
-
278
- ### Usage C# ⌨
279
-
280
- C# support is provided by:
281
- [vycdev/ColorNamesSharp](https://github.com/vycdev/ColorNamesSharp)
282
- See the repository for more details; basic usage is below:
283
-
284
- The library is available as a [nuget package](https://www.nuget.org/packages/ColorNamesSharp)
285
-
286
- #### Creating the instance
175
+ ### Java/Kotlin, C#, Rust
287
176
 
288
- ```csharp
289
- ColorNames colorNames = new ColorNamesBuilder()
290
- .Add("Best Blue", "#3299fe") // Add your own custom colors
291
- .LoadDefault() // Load the default color list
292
- .AddFromCsv("path/to/your/colorlist.csv") // Add a custom color list from a csv file
293
- .Build(); // Get a new ColorNames instance that includes all the colors you've added
294
- ```
295
-
296
- #### Getting a fitting color name
297
-
298
- ```csharp
299
- NamedColor customNamedColor = new("Custom Named Color", 50, 153, 254);
177
+ Moved to docs:
300
178
 
301
- // You can directly get the name of the color as a string
302
- string colorNameFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
303
- string colorNameFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
304
- string colorNameFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
305
-
306
- // Or similarly you can get the NamedColor object
307
- NamedColor namedColorFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
308
- NamedColor namedColorFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
309
- NamedColor namedColorFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
310
-
311
- // Or a random color
312
- NamedColor randomColor = colorNames.GetRandomNamedColor();
313
- ```
179
+ - [docs/usage-java-kotlin.md](docs/usage-java-kotlin.md)
180
+ - [docs/usage-csharp.md](docs/usage-csharp.md)
181
+ - [docs/usage-rust.md](docs/usage-rust.md)
314
182
 
315
183
  ### Usage Rust
316
184
 
317
- Rust support is provided by
318
- [philocalyst/color-names](https://github.com/philocalyst/color-names).
319
- You can add it to your rust project with `cargo add colorsnamed`. See the
320
- repository for more details. Basic usage is below.
321
-
322
- #### Choosing colors
323
-
324
- ```rust
325
- use colorsnamed;
326
-
327
- let black = colorsnamed::Basic::Black;
328
- let teal = colorsnamed::Basic::Teal;
329
- let another = colorsnamed::Xkcd::Tea;
330
- ```
331
-
332
- #### Getting colors
333
-
334
- ```rust
335
- use colorsnamed;
336
-
337
- // Get the relevant hex code
338
- let red = colorsnamed::Basic::Red;
339
- let hex = red.hex();
340
-
341
- // Figure out if there is a matching color for a hex code!
342
- let ex: colorsnamed::Basic = hex.try_into().unwrap();
343
- ```
344
-
345
- #### Converting colors
346
-
347
- ```rust
348
- use colorsnamed;
349
- use colors;
350
- use rgb::Rgb;
351
-
352
- // Convert to the represention of your colorspace of choice.
353
- let correct_color = red.color::<colors::Srgb>();
354
-
355
- let red = colorsnamed::Basic::Red;
356
-
357
- // Get the RGB representation
358
- let rgb: Rgb = red.rgb();
359
- ```
185
+ See [docs/usage-rust.md](docs/usage-rust.md).
360
186
 
361
187
  ## Sources πŸ—’
362
188
 
@@ -493,11 +319,6 @@ so we can address them promptly.
493
319
  [Color Distribution]: https://codepen.io/meodai/full/zdgXJj/
494
320
  [Twitter Bot]: https://twitter.com/color_parrot
495
321
 
496
- <!-- 3r party libraries & tools -->
497
-
498
- [ClosestVector]: https://github.com/meodai/ClosestVector
499
- [nearest-color]: https://github.com/dtao/nearest-color
500
-
501
322
  <!-- people -->
502
323
 
503
324
  [Ichatdelune]: https://www.reddit.com/user/Ichatdelune
@@ -0,0 +1,38 @@
1
+ # C# Usage
2
+
3
+ C# support is provided by
4
+ [vycdev/ColorNamesSharp](https://github.com/vycdev/ColorNamesSharp).
5
+ The library is available as a
6
+ [NuGet package](https://www.nuget.org/packages/ColorNamesSharp).
7
+
8
+ ## Creating the instance
9
+
10
+ ```csharp
11
+ ColorNames colorNames = new ColorNamesBuilder()
12
+ .Add("Best Blue", "#3299fe") // Add your own custom colors
13
+ .LoadDefault() // Load the default color list
14
+ .AddFromCsv("path/to/your/colorlist.csv") // Add a custom color list from a csv file
15
+ .Build(); // Get a new ColorNames instance that includes all the colors you've added
16
+ ```
17
+
18
+ ## Getting a fitting color name
19
+
20
+ ```csharp
21
+ NamedColor customNamedColor = new("Custom Named Color", 50, 153, 254);
22
+
23
+ // You can directly get the name of the color as a string
24
+ string colorNameFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
25
+ string colorNameFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
26
+ string colorNameFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
27
+
28
+ // Or similarly you can get the NamedColor object
29
+ NamedColor namedColorFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
30
+ NamedColor namedColorFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
31
+ NamedColor namedColorFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
32
+
33
+ // Or a random color
34
+ NamedColor randomColor = colorNames.GetRandomNamedColor();
35
+ ```
36
+
37
+ See the upstream project for more details and updates:
38
+ [vycdev/ColorNamesSharp](https://github.com/vycdev/ColorNamesSharp)
@@ -0,0 +1,58 @@
1
+ # Java / Kotlin Usage
2
+
3
+ Java/Kotlin support is provided by
4
+ [UwUAroze/Color-Names](https://github.com/UwUAroze/Color-Names).
5
+
6
+ ## Gradle (Kotlin DSL)
7
+
8
+ ```kts
9
+ repositories {
10
+ maven("https://jitpack.io")
11
+ }
12
+
13
+ dependencies {
14
+ implementation("me.aroze:color-names:1.0.4")
15
+ }
16
+ ```
17
+
18
+ ## Maven
19
+
20
+ ```xml
21
+ <repository>
22
+ <id>jitpack.io</id>
23
+ <url>https://jitpack.io</url>
24
+ </repository>
25
+
26
+ <dependency>
27
+ <groupId>me.aroze</groupId>
28
+ <artifactId>color-names</artifactId>
29
+ <version>1.0.4</version>
30
+ </dependency>
31
+ ```
32
+
33
+ ## Closest Named Color (Java)
34
+
35
+ ```java
36
+ public ColorNames colorNames = new ColorNameBuilder()
37
+ .loadDefaults()
38
+ .build();
39
+
40
+ String fromHex = colorNames.getName("#facfea"); // "Classic Rose"
41
+ String fromRGB = colorNames.getName(224, 224, 255); // "Stoic White"
42
+ String fromColor = colorNames.getName(new Color(255, 219, 240)); // "Silky Pink"
43
+ ```
44
+
45
+ ## Closest Named Color (Kotlin)
46
+
47
+ ```kt
48
+ val colorNames = ColorNameBuilder()
49
+ .loadDefaults()
50
+ .build()
51
+
52
+ val fromHex = colorNames.getName("#facfea") // "Classic Rose"
53
+ val fromRGB = colorNames.getName(224, 224, 255) // "Stoic White"
54
+ val fromColor = colorNames.getName(Color(255, 219, 240)) // "Silky Pink"
55
+ ```
56
+
57
+ See the upstream project for more details and updates:
58
+ [UwUAroze/Color-Names](https://github.com/UwUAroze/Color-Names)
@@ -0,0 +1,81 @@
1
+ # JavaScript / TypeScript Usage
2
+
3
+ This guide shows how to use the color list from JavaScript and
4
+ TypeScript projects. It covers ESM and CommonJS usage and finding the
5
+ closest named color.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install color-name-list
11
+ ```
12
+
13
+ ## Data Shape
14
+
15
+ ```ts
16
+ type ColorName = { name: string; hex: string };
17
+ ```
18
+
19
+ ## ESM (Node/Browser Bundlers)
20
+
21
+ ```js
22
+ import { colornames } from 'color-name-list';
23
+
24
+ const white = colornames.find((c) => c.hex === '#ffffff');
25
+ console.log(white.name); // => white
26
+
27
+ const eigengrau = colornames.find((c) => c.name === 'Eigengrau');
28
+ console.log(eigengrau?.hex); // => #16161d
29
+ ```
30
+
31
+ ## CommonJS (require)
32
+
33
+ ```js
34
+ // When required, the package returns the array of color objects directly
35
+ const colornames = require('color-name-list');
36
+
37
+ const white = colornames.find((c) => c.hex === '#ffffff');
38
+ console.log(white.name); // => white
39
+ ```
40
+
41
+ ## Find the Closest Named Color
42
+
43
+ With 16,777,216 possible RGB colors, you may want to use a helper like
44
+ `nearest-color` or `ClosestVector`.
45
+
46
+ ```js
47
+ import nearestColor from 'nearest-color';
48
+ import { colornames } from 'color-name-list';
49
+
50
+ // nearestColor expects an object { name => hex }
51
+ const colors = colornames.reduce((o, { name, hex }) => Object.assign(o, { [name]: hex }), {});
52
+ const nearest = nearestColor.from(colors);
53
+
54
+ // Get closest named color
55
+ nearest('#f1c1d1'); // => Fairy Tale
56
+ ```
57
+
58
+ Note: For better visual accuracy, consider DeltaE or using CIECAM02
59
+ instead of raw RGB distance:
60
+
61
+ - [DeltaE](https://github.com/zschuessler/DeltaE)
62
+ - [CIECAM02](https://github.com/baskerville/ciecam02)
63
+
64
+ ## Subsets and Performance Tips
65
+
66
+ - Best-of subset (smaller list):
67
+ - ESM: `import { colornames as bestof } from 'color-name-list/bestof'`
68
+ - UMD: `https://unpkg.com/color-name-list/dist/colornames.bestof.umd.js`
69
+ - Short subset (< 13 characters, best-of filtered): `dist/colornames.short.*`
70
+ - For browsers, prefer the public API for payload-sensitive scenarios:
71
+ [Color Name API](https://github.com/meodai/color-name-api)
72
+
73
+ ## CDN (Reproducible)
74
+
75
+ - Latest: `https://unpkg.com/color-name-list/dist/colornames.min.json`
76
+ - Pinned: `https://unpkg.com/color-name-list@<version>/dist/colornames.min.json`
77
+
78
+ ## Types
79
+
80
+ The package ships ESM. For TypeScript projects, you can declare the data
81
+ shape as shown above or infer it directly from usage.
@@ -0,0 +1,51 @@
1
+ # Rust Usage
2
+
3
+ Rust support is provided by
4
+ [philocalyst/color-names](https://github.com/philocalyst/color-names).
5
+ Add it with:
6
+
7
+ ```sh
8
+ cargo add colorsnamed
9
+ ```
10
+
11
+ ## Choosing colors
12
+
13
+ ```rust
14
+ use colorsnamed;
15
+
16
+ let black = colorsnamed::Basic::Black;
17
+ let teal = colorsnamed::Basic::Teal;
18
+ let another = colorsnamed::Xkcd::Tea;
19
+ ```
20
+
21
+ ## Getting colors
22
+
23
+ ```rust
24
+ use colorsnamed;
25
+
26
+ // Get the relevant hex code
27
+ let red = colorsnamed::Basic::Red;
28
+ let hex = red.hex();
29
+
30
+ // Figure out if there is a matching color for a hex code!
31
+ let ex: colorsnamed::Basic = hex.try_into().unwrap();
32
+ ```
33
+
34
+ ## Converting colors
35
+
36
+ ```rust
37
+ use colorsnamed;
38
+ use colors;
39
+ use rgb::Rgb;
40
+
41
+ // Convert to the representation of your colorspace of choice.
42
+ let correct_color = red.color::<colors::Srgb>();
43
+
44
+ let red = colorsnamed::Basic::Red;
45
+
46
+ // Get the RGB representation
47
+ let rgb: Rgb = red.rgb();
48
+ ```
49
+
50
+ See the upstream project for more details and updates:
51
+ [philocalyst/color-names](https://github.com/philocalyst/color-names)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "color-name-list",
3
- "version": "13.13.1",
3
+ "version": "13.14.0",
4
4
  "description": "long list of color names",
5
5
  "main": "dist/colornames.json",
6
6
  "browser": "dist/colornames.umd.js",