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.
@@ -15,7 +15,7 @@ jobs:
15
15
 
16
16
  strategy:
17
17
  matrix:
18
- node-version: [15.x, 16.x]
18
+ node-version: [20.x]
19
19
 
20
20
  steps:
21
21
  - uses: actions/checkout@v2
@@ -14,7 +14,7 @@ jobs:
14
14
  - name: Setup Node.js
15
15
  uses: actions/setup-node@v1
16
16
  with:
17
- node-version: 19
17
+ node-version: 20
18
18
  - name: Install dependencies
19
19
  run: npm ci
20
20
  - name: Test
@@ -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</a>
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 { colorNameList } from 'color-name-list';
138
+ import { colornames } from 'color-name-list';
139
139
 
140
- let someColor = colorNameList.find(color => color.hex === '#ffffff');
140
+ let someColor = colornames.find(color => color.hex === '#ffffff');
141
141
  console.log(someColor.name); // => white
142
142
 
143
- let someNamedColor = colorNameList.find(color => color.name === 'Eigengrau')
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 { colorNameList } from 'color-name-list';
154
+ import { colornames } from 'color-name-list';
155
155
 
156
156
  // nearestColor need objects {name => hex} as input
157
- const colors = colorNameList.reduce((o, { name, hex }) => Object.assign(o, { [name]: hex }), {});
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 📇