color-name-list 13.13.0 β†’ 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/CONTRIBUTING.md CHANGED
@@ -7,17 +7,26 @@ interactions with the project.
7
7
 
8
8
  ## Adding colors
9
9
 
10
- 1. Only update the `src/colornames.csv` file and run `npm run test`
10
+ 1. Only update the `src/colornames.csv` file and run `npm test`.
11
11
  2. Make sure the names you commit are not racist or offensive or a protected
12
12
  brand name (No Facebook Blue, Coca Cola Red etc.., no nationality or tan etc..).
13
13
  3. Read the "Rules for new color names" directly below
14
14
  4. Make sure that neither name nor hex value of your added colors are already
15
- in use. `npm run test` will test that for you.
16
- 5. Update the `README.md` with the source of your colors, unless you invented
17
- that color, in this case add yourself to the contributors in the `README.md`
15
+ in use. `npm test` will test that for you.
16
+ 5. Do not edit generated files. Do not commit changes to `README.md`,
17
+ `changes.svg` or anything in `dist/`.
18
+ 6. Add the source of your colors in the Pull Request description.
19
+ Maintainers will update documentation if needed.
18
20
 
19
21
  **We use automated semantic versioning** make sure to use git cz (or npm run commit).
20
22
 
23
+ ## Generated files and CI
24
+
25
+ - PRs run `npm ci`, `npm run build`, and `npm test` in CI.
26
+ - CI may update `README.md` and `changes.svg` automatically and push
27
+ to your PR branch.
28
+ - Do not include generated files (`dist/`, `README.md`, `changes.svg`) in commits.
29
+
21
30
  ## Rules for new color names
22
31
 
23
32
  - No duplicate names or hex values.
@@ -41,6 +50,7 @@ interactions with the project.
41
50
  **feat(colors): Add fantastic new colors names.** rather then
42
51
  feat(colors): Added new names.
43
52
  - Make sure to run `npm run test` before committing.
53
+ For color name changes this is the only command you need locally.
44
54
 
45
55
  ### Attribution
46
56
 
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>
@@ -62,7 +61,18 @@ Please review the [naming rules](CONTRIBUTING.md) before contributing!
62
61
  ### Contributing via Git πŸ«±πŸ½β€πŸ«²πŸ»
63
62
 
64
63
  To contribute via Git, edit the `src/colornames.csv` file
65
- and ensure it builds correctly (`npm run ci && npm run build`).
64
+ and ensure tests pass locally (`npm test`).
65
+
66
+ See the full guidelines in [CONTRIBUTING.md](CONTRIBUTING.md).
67
+
68
+ CI notes:
69
+
70
+ - Pull Requests run `npm ci`, `npm run build`, and `npm test`.
71
+ - CI auto-updates `README.md` and `changes.svg` if needed and pushes to your PR branch.
72
+ - Do not commit generated files (`dist/`, `changes.svg`).
73
+ - For color name changes, only submit updates to `src/colornames.csv`.
74
+ - No need to run `npm run build` locally; CI generates outputs.
75
+ - Optional locally: `npm run lint:markdown` to match CI markdown checks.
66
76
 
67
77
  ## Color Count: __29985__ πŸŽ‰
68
78
 
@@ -80,23 +90,19 @@ color space: [Visualization](https://codepen.io/meodai/full/zdgXJj/)
80
90
 
81
91
  ## Usage πŸ“–
82
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
+
83
100
  ### Consuming the list
84
101
 
85
102
  The list is available in [multiple formats](https://app.unpkg.com/color-name-list/files/dist),
86
103
  or you can use the [public REST API](#api-), making it easy to integrate into
87
104
  your project.
88
105
 
89
- ### Node.js Installation πŸ“¦
90
-
91
- __Size Warning (1.14 MB)__: For browser usage,
92
- consider the [public rest API](#api-)
93
-
94
- ```shell
95
- npm install color-name-list --save
96
- ```
97
-
98
- or `yarn add color-name-list`
99
-
100
106
  ### CDN 🌍
101
107
 
102
108
  #### All Names πŸ“š
@@ -122,6 +128,22 @@ or `yarn add color-name-list`
122
128
  / [SCSS](https://unpkg.com/color-name-list/dist/colornames.bestof.scss)
123
129
  / [CSS](https://unpkg.com/color-name-list/dist/colornames.bestof.css)
124
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
+
125
147
  ### API πŸƒ
126
148
 
127
149
  To simplify access, we provide a free and public REST API for all color names
@@ -142,47 +164,6 @@ generates excessive traffic, you may be asked to become a sponsor.
142
164
  You are welcome to self-host the APIβ€”it's easy to deploy on Heroku and relies
143
165
  only on a few dependencies: [Color-Name-API](https://github.com/meodai/color-name-api)
144
166
 
145
- ### Usage JS ⌨
146
-
147
- __Size Warning (1.16 MB)__: For browser usage,
148
- consider the [public rest API](#api-)
149
-
150
- #### Exact Color
151
-
152
- ```javascript
153
- import { colornames } from 'color-name-list';
154
-
155
- let someColor = colornames.find((color) => color.hex === '#ffffff');
156
- console.log(someColor.name); // => white
157
-
158
- let someNamedColor = colornames.find((color) => color.name === 'Eigengrau');
159
- console.log(someColor.hex); // => #16161d
160
- ```
161
-
162
- #### Closest Named Color
163
-
164
- With 16,777,216 possible RGB colors, you may want to use a library such as
165
- [nearest-color] or [ClosestVector] to find the closest named color.
166
-
167
- ```js
168
- import nearestColor from 'nearest-color';
169
- import { colornames } from 'color-name-list';
170
-
171
- // nearestColor expects an object {name => hex}
172
- const colors = colornames.reduce((o, { name, hex }) => Object.assign(o, { [name]: hex }), {});
173
-
174
- const nearest = nearestColor.from(colors);
175
-
176
- // get closest named color
177
- nearest('#f1c1d1'); // => Fairy Tale
178
- ```
179
-
180
- __Note__: For greater visual accuracy, consider using [DeltaE] or the above
181
- approach with [ciecam02] instead of RGB.
182
-
183
- [DeltaE]: https://github.com/zschuessler/DeltaE
184
- [ciecam02]: https://github.com/baskerville/ciecam02
185
-
186
167
  ### Building πŸ”¨
187
168
 
188
169
  ```shell
@@ -191,145 +172,17 @@ npm install && npm run build
191
172
 
192
173
  See [package.json](package.json#L6) for details.
193
174
 
194
- ### Usage Java/Kotlin ⌨
175
+ ### Java/Kotlin, C#, Rust
195
176
 
196
- Java/Kotlin support is provided by:
197
- [UwUAroze/Color-Names](https://github.com/UwUAroze/Color-Names).
198
- See the repository for more, or use the basics below:
177
+ Moved to docs:
199
178
 
200
- #### Importing - Gradle.kts
201
-
202
- ```kts
203
- repositories {
204
- maven("https://jitpack.io")
205
- }
206
-
207
- dependencies {
208
- implementation("me.aroze:color-names:1.0.4")
209
- }
210
- ```
211
-
212
- #### Importing - Maven
213
-
214
- ```xml
215
- <repository>
216
- <id>jitpack.io</id>
217
- <url>https://jitpack.io</url>
218
- </repository>
219
-
220
- <dependency>
221
- <groupId>me.aroze</groupId>
222
- <artifactId>color-names</artifactId>
223
- <version>1.0.4</version>
224
- </dependency>
225
- ```
226
-
227
- #### Closest named color - Java
228
-
229
- ```java
230
- public ColorNames colorNames = new ColorNameBuilder()
231
- .loadDefaults()
232
- .build();
233
-
234
- String fromHex = colorNames.getName("#facfea"); // "Classic Rose"
235
- String fromRGB = colorNames.getName(224, 224, 255); // "Stoic White"
236
- String fromColor = colorNames.getName(new Color(255, 219, 240)); // "Silky Pink"
237
- ```
238
-
239
- #### Closest named color - Kotlin
240
-
241
- ```kt
242
- val colorNames = ColorNameBuilder()
243
- .loadDefaults()
244
- .build()
245
-
246
- val fromHex = colorNames.getName("#facfea") // "Classic Rose"
247
- val fromRGB = colorNames.getName(224, 224, 255) // "Stoic White"
248
- val fromColor = colorNames.getName(Color(255, 219, 240)) // "Silky Pink"
249
- ```
250
-
251
- ### Usage C# ⌨
252
-
253
- C# support is provided by:
254
- [vycdev/ColorNamesSharp](https://github.com/vycdev/ColorNamesSharp)
255
- See the repository for more details; basic usage is below:
256
-
257
- The library is available as a [nuget package](https://www.nuget.org/packages/ColorNamesSharp)
258
-
259
- #### Creating the instance
260
-
261
- ```csharp
262
- ColorNames colorNames = new ColorNamesBuilder()
263
- .Add("Best Blue", "#3299fe") // Add your own custom colors
264
- .LoadDefault() // Load the default color list
265
- .AddFromCsv("path/to/your/colorlist.csv") // Add a custom color list from a csv file
266
- .Build(); // Get a new ColorNames instance that includes all the colors you've added
267
- ```
268
-
269
- #### Getting a fitting color name
270
-
271
- ```csharp
272
- NamedColor customNamedColor = new("Custom Named Color", 50, 153, 254);
273
-
274
- // You can directly get the name of the color as a string
275
- string colorNameFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
276
- string colorNameFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
277
- string colorNameFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
278
-
279
- // Or similarly you can get the NamedColor object
280
- NamedColor namedColorFromHex = colorNames.FindClosestColorName("#facfea"); // Classic Rose
281
- NamedColor namedColorFromRgb = colorNames.FindClosestColorName(224, 224, 255); // Stoic White
282
- NamedColor namedColorFromNamedColor = colorNames.FindClosestColorName(customNamedColor); // Best Blue
283
-
284
- // Or a random color
285
- NamedColor randomColor = colorNames.GetRandomNamedColor();
286
- ```
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)
287
182
 
288
183
  ### Usage Rust
289
184
 
290
- Rust support is provided by
291
- [philocalyst/color-names](https://github.com/philocalyst/color-names).
292
- You can add it to your rust project with `cargo add colorsnamed`. See the
293
- repository for more details. Basic usage is below.
294
-
295
- #### Choosing colors
296
-
297
- ```rust
298
- use colorsnamed;
299
-
300
- let black = colorsnamed::Basic::Black;
301
- let teal = colorsnamed::Basic::Teal;
302
- let another = colorsnamed::Xkcd::Tea;
303
- ```
304
-
305
- #### Getting colors
306
-
307
- ```rust
308
- use colorsnamed;
309
-
310
- // Get the relevant hex code
311
- let red = colorsnamed::Basic::Red;
312
- let hex = red.hex();
313
-
314
- // Figure out if there is a matching color for a hex code!
315
- let ex: colorsnamed::Basic = hex.try_into().unwrap();
316
- ```
317
-
318
- #### Converting colors
319
-
320
- ```rust
321
- use colorsnamed;
322
- use colors;
323
- use rgb::Rgb;
324
-
325
- // Convert to the represention of your colorspace of choice.
326
- let correct_color = red.color::<colors::Srgb>();
327
-
328
- let red = colorsnamed::Basic::Red;
329
-
330
- // Get the RGB representation
331
- let rgb: Rgb = red.rgb();
332
- ```
185
+ See [docs/usage-rust.md](docs/usage-rust.md).
333
186
 
334
187
  ## Sources πŸ—’
335
188
 
@@ -466,11 +319,6 @@ so we can address them promptly.
466
319
  [Color Distribution]: https://codepen.io/meodai/full/zdgXJj/
467
320
  [Twitter Bot]: https://twitter.com/color_parrot
468
321
 
469
- <!-- 3r party libraries & tools -->
470
-
471
- [ClosestVector]: https://github.com/meodai/ClosestVector
472
- [nearest-color]: https://github.com/dtao/nearest-color
473
-
474
322
  <!-- people -->
475
323
 
476
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.0",
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",
package/scripts/build.js CHANGED
@@ -288,8 +288,8 @@ fs.writeFileSync(
288
288
  `__${((colorsSrc.entries.length / (256 * 256 * 256)) * 100).toFixed(2)}%__`
289
289
  )
290
290
  .replace(
291
- // update file size
292
- /\d+(\.\d+)? MB\)__/, // no global to only hit first occurrence
291
+ // update file size (update all occurrences)
292
+ /\d+(\.\d+)? MB\)__+/g,
293
293
  `${(
294
294
  fs.statSync(path.normalize(`${baseFolder}${folderDist}${fileNameSrc}.json`)).size /
295
295
  1024 /