color-name-list 10.0.0 → 10.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.
@@ -13329,6 +13329,10 @@
13329
13329
  <hex>#463d2f</hex>
13330
13330
  </color>
13331
13331
  <color>
13332
+ <name>Bold Gold</name>
13333
+ <hex>#ead56d</hex>
13334
+ </color>
13335
+ <color>
13332
13336
  <name>Bold Irish</name>
13333
13337
  <hex>#2a814d</hex>
13334
13338
  </color>
@@ -21281,7 +21285,7 @@
21281
21285
  <hex>#d1d5e7</hex>
21282
21286
  </color>
21283
21287
  <color>
21284
- <name>Chill of Teamwork</name>
21288
+ <name>Chill of the Night</name>
21285
21289
  <hex>#256d8d</hex>
21286
21290
  </color>
21287
21291
  <color>
@@ -25709,6 +25713,10 @@
25709
25713
  <hex>#cadada</hex>
25710
25714
  </color>
25711
25715
  <color>
25716
+ <name>Cosmic Red</name>
25717
+ <hex>#da244b</hex>
25718
+ </color>
25719
+ <color>
25712
25720
  <name>Cosmic Sky</name>
25713
25721
  <hex>#aaaac4</hex>
25714
25722
  </color>
@@ -32265,6 +32273,10 @@
32265
32273
  <hex>#594158</hex>
32266
32274
  </color>
32267
32275
  <color>
32276
+ <name>Dreamy Memory</name>
32277
+ <hex>#e8c3d9</hex>
32278
+ </color>
32279
+ <color>
32268
32280
  <name>Dreamy Pink</name>
32269
32281
  <hex>#dfabcd</hex>
32270
32282
  </color>
@@ -41869,6 +41881,10 @@
41869
41881
  <hex>#e0dfdb</hex>
41870
41882
  </color>
41871
41883
  <color>
41884
+ <name>Galactic Purple</name>
41885
+ <hex>#472e97</hex>
41886
+ </color>
41887
+ <color>
41872
41888
  <name>Galactic Tint</name>
41873
41889
  <hex>#c0c4c6</hex>
41874
41890
  </color>
@@ -56329,6 +56345,10 @@
56329
56345
  <hex>#8a0009</hex>
56330
56346
  </color>
56331
56347
  <color>
56348
+ <name>Kiss of Lime</name>
56349
+ <hex>#eae2ac</hex>
56350
+ </color>
56351
+ <color>
56332
56352
  <name>Kiss of the Scorpion</name>
56333
56353
  <hex>#dc331a</hex>
56334
56354
  </color>
@@ -57029,6 +57049,10 @@
57029
57049
  <hex>#e3e3ea</hex>
57030
57050
  </color>
57031
57051
  <color>
57052
+ <name>Ladybug</name>
57053
+ <hex>#bd474e</hex>
57054
+ </color>
57055
+ <color>
57032
57056
  <name>Ladylike</name>
57033
57057
  <hex>#ffc3bf</hex>
57034
57058
  </color>
@@ -58273,6 +58297,10 @@
58273
58297
  <hex>#f5c71a</hex>
58274
58298
  </color>
58275
58299
  <color>
58300
+ <name>Lees</name>
58301
+ <hex>#4c2226</hex>
58302
+ </color>
58303
+ <color>
58276
58304
  <name>Left on Red</name>
58277
58305
  <hex>#ff0303</hex>
58278
58306
  </color>
@@ -60445,6 +60473,10 @@
60445
60473
  <hex>#cc99ff</hex>
60446
60474
  </color>
60447
60475
  <color>
60476
+ <name>Lili Elbe's Pink</name>
60477
+ <hex>#d4a1b0</hex>
60478
+ </color>
60479
+ <color>
60448
60480
  <name>Liliac</name>
60449
60481
  <hex>#c48efd</hex>
60450
60482
  </color>
@@ -62381,6 +62413,10 @@
62381
62413
  <hex>#e0ddd8</hex>
62382
62414
  </color>
62383
62415
  <color>
62416
+ <name>Lunar Luxury</name>
62417
+ <hex>#fbf4d6</hex>
62418
+ </color>
62419
+ <color>
62384
62420
  <name>Lunar Outpost</name>
62385
62421
  <hex>#828287</hex>
62386
62422
  </color>
@@ -72753,6 +72789,10 @@
72753
72789
  <hex>#e1dcda</hex>
72754
72790
  </color>
72755
72791
  <color>
72792
+ <name>Nova Pink</name>
72793
+ <hex>#d94f9a</hex>
72794
+ </color>
72795
+ <color>
72756
72796
  <name>Nova White</name>
72757
72797
  <hex>#f8eed9</hex>
72758
72798
  </color>
@@ -80489,6 +80529,10 @@
80489
80529
  <hex>#57593f</hex>
80490
80530
  </color>
80491
80531
  <color>
80532
+ <name>Pineweed</name>
80533
+ <hex>#5b7349</hex>
80534
+ </color>
80535
+ <color>
80492
80536
  <name>Piney Lake</name>
80493
80537
  <hex>#006655</hex>
80494
80538
  </color>
@@ -104369,6 +104413,10 @@
104369
104413
  <hex>#9787bb</hex>
104370
104414
  </color>
104371
104415
  <color>
104416
+ <name>Sunlit Glade</name>
104417
+ <hex>#98d4a0</hex>
104418
+ </color>
104419
+ <color>
104372
104420
  <name>Sunlit Kelp Green</name>
104373
104421
  <hex>#7d7103</hex>
104374
104422
  </color>
@@ -110486,7 +110534,7 @@
110486
110534
  </color>
110487
110535
  <color>
110488
110536
  <name>Turf</name>
110489
- <hex>#5f4f42</hex>
110537
+ <hex>#415b36</hex>
110490
110538
  </color>
110491
110539
  <color>
110492
110540
  <name>Turf Green</name>
@@ -110497,6 +110545,10 @@
110497
110545
  <hex>#009922</hex>
110498
110546
  </color>
110499
110547
  <color>
110548
+ <name>Turf War</name>
110549
+ <hex>#738050</hex>
110550
+ </color>
110551
+ <color>
110500
110552
  <name>Turkish Aqua</name>
110501
110553
  <hex>#006169</hex>
110502
110554
  </color>
@@ -115993,6 +116045,10 @@
115993
116045
  <hex>#cbede5</hex>
115994
116046
  </color>
115995
116047
  <color>
116048
+ <name>Whisper of Plum</name>
116049
+ <hex>#d4afda</hex>
116050
+ </color>
116051
+ <color>
115996
116052
  <name>Whisper of Rose</name>
115997
116053
  <hex>#cda2ac</hex>
115998
116054
  </color>
@@ -116697,10 +116753,6 @@
116697
116753
  <hex>#ee9900</hex>
116698
116754
  </color>
116699
116755
  <color>
116700
- <name>Wiggle</name>
116701
- <hex>#c9c844</hex>
116702
- </color>
116703
- <color>
116704
116756
  <name>Wild Apple</name>
116705
116757
  <hex>#fef9d7</hex>
116706
116758
  </color>
@@ -9994,6 +9994,9 @@
9994
9994
  -
9995
9995
  name:"Bold Eagle"
9996
9996
  hex:"#463d2f"
9997
+ -
9998
+ name:"Bold Gold"
9999
+ hex:"#ead56d"
9997
10000
  -
9998
10001
  name:"Bold Irish"
9999
10002
  hex:"#2a814d"
@@ -15959,7 +15962,7 @@
15959
15962
  name:"Chill in the Air"
15960
15963
  hex:"#d1d5e7"
15961
15964
  -
15962
- name:"Chill of Teamwork"
15965
+ name:"Chill of the Night"
15963
15966
  hex:"#256d8d"
15964
15967
  -
15965
15968
  name:"Chilled Chilly"
@@ -19279,6 +19282,9 @@
19279
19282
  -
19280
19283
  name:"Cosmic Ray"
19281
19284
  hex:"#cadada"
19285
+ -
19286
+ name:"Cosmic Red"
19287
+ hex:"#da244b"
19282
19288
  -
19283
19289
  name:"Cosmic Sky"
19284
19290
  hex:"#aaaac4"
@@ -24196,6 +24202,9 @@
24196
24202
  -
24197
24203
  name:"Dreamy Heaven"
24198
24204
  hex:"#594158"
24205
+ -
24206
+ name:"Dreamy Memory"
24207
+ hex:"#e8c3d9"
24199
24208
  -
24200
24209
  name:"Dreamy Pink"
24201
24210
  hex:"#dfabcd"
@@ -31399,6 +31408,9 @@
31399
31408
  -
31400
31409
  name:"Galactic Mediator"
31401
31410
  hex:"#e0dfdb"
31411
+ -
31412
+ name:"Galactic Purple"
31413
+ hex:"#472e97"
31402
31414
  -
31403
31415
  name:"Galactic Tint"
31404
31416
  hex:"#c0c4c6"
@@ -42244,6 +42256,9 @@
42244
42256
  -
42245
42257
  name:"Kiss of a Vampire"
42246
42258
  hex:"#8a0009"
42259
+ -
42260
+ name:"Kiss of Lime"
42261
+ hex:"#eae2ac"
42247
42262
  -
42248
42263
  name:"Kiss of the Scorpion"
42249
42264
  hex:"#dc331a"
@@ -42769,6 +42784,9 @@
42769
42784
  -
42770
42785
  name:"Lady's Slipper"
42771
42786
  hex:"#e3e3ea"
42787
+ -
42788
+ name:"Ladybug"
42789
+ hex:"#bd474e"
42772
42790
  -
42773
42791
  name:"Ladylike"
42774
42792
  hex:"#ffc3bf"
@@ -43702,6 +43720,9 @@
43702
43720
  -
43703
43721
  name:"Leery Lemon"
43704
43722
  hex:"#f5c71a"
43723
+ -
43724
+ name:"Lees"
43725
+ hex:"#4c2226"
43705
43726
  -
43706
43727
  name:"Left on Red"
43707
43728
  hex:"#ff0303"
@@ -45331,6 +45352,9 @@
45331
45352
  -
45332
45353
  name:"Lilás"
45333
45354
  hex:"#cc99ff"
45355
+ -
45356
+ name:"Lili Elbe's Pink"
45357
+ hex:"#d4a1b0"
45334
45358
  -
45335
45359
  name:"Liliac"
45336
45360
  hex:"#c48efd"
@@ -46783,6 +46807,9 @@
46783
46807
  -
46784
46808
  name:"Lunar Lite"
46785
46809
  hex:"#e0ddd8"
46810
+ -
46811
+ name:"Lunar Luxury"
46812
+ hex:"#fbf4d6"
46786
46813
  -
46787
46814
  name:"Lunar Outpost"
46788
46815
  hex:"#828287"
@@ -54562,6 +54589,9 @@
54562
54589
  -
54563
54590
  name:"Nouvelle White"
54564
54591
  hex:"#e1dcda"
54592
+ -
54593
+ name:"Nova Pink"
54594
+ hex:"#d94f9a"
54565
54595
  -
54566
54596
  name:"Nova White"
54567
54597
  hex:"#f8eed9"
@@ -60364,6 +60394,9 @@
60364
60394
  -
60365
60395
  name:"Pinetop"
60366
60396
  hex:"#57593f"
60397
+ -
60398
+ name:"Pineweed"
60399
+ hex:"#5b7349"
60367
60400
  -
60368
60401
  name:"Piney Lake"
60369
60402
  hex:"#006655"
@@ -78274,6 +78307,9 @@
78274
78307
  -
78275
78308
  name:"Sunlit Allium"
78276
78309
  hex:"#9787bb"
78310
+ -
78311
+ name:"Sunlit Glade"
78312
+ hex:"#98d4a0"
78277
78313
  -
78278
78314
  name:"Sunlit Kelp Green"
78279
78315
  hex:"#7d7103"
@@ -82863,13 +82899,16 @@
82863
82899
  hex:"#536a79"
82864
82900
  -
82865
82901
  name:"Turf"
82866
- hex:"#5f4f42"
82902
+ hex:"#415b36"
82867
82903
  -
82868
82904
  name:"Turf Green"
82869
82905
  hex:"#2a8948"
82870
82906
  -
82871
82907
  name:"Turf Master"
82872
82908
  hex:"#009922"
82909
+ -
82910
+ name:"Turf War"
82911
+ hex:"#738050"
82873
82912
  -
82874
82913
  name:"Turkish Aqua"
82875
82914
  hex:"#006169"
@@ -86992,6 +87031,9 @@
86992
87031
  -
86993
87032
  name:"Whisper of Grass"
86994
87033
  hex:"#cbede5"
87034
+ -
87035
+ name:"Whisper of Plum"
87036
+ hex:"#d4afda"
86995
87037
  -
86996
87038
  name:"Whisper of Rose"
86997
87039
  hex:"#cda2ac"
@@ -87520,9 +87562,6 @@
87520
87562
  -
87521
87563
  name:"Wiener Schnitzel"
87522
87564
  hex:"#ee9900"
87523
- -
87524
- name:"Wiggle"
87525
- hex:"#c9c844"
87526
87565
  -
87527
87566
  name:"Wild Apple"
87528
87567
  hex:"#fef9d7"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "color-name-list",
3
- "version": "10.0.0",
3
+ "version": "10.1.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
@@ -257,13 +257,24 @@ const readme = fs.readFileSync(
257
257
  ).toString();
258
258
  fs.writeFileSync(
259
259
  path.normalize(`${baseFolder}${readmeFileName}`),
260
- readme.replace(/__\d+__/g, `__${colorsSrc.entires.length}__`)
261
- .replace(
260
+ readme.replace(
261
+ // update color count in text
262
+ /__\d+__/g,
263
+ `__${colorsSrc.entires.length}__`
264
+ ).replace(
265
+ // update color count in badge
262
266
  /\d+-colors-orange/,
263
267
  `${colorsSrc.entires.length}-colors-orange`
264
268
  ).replace(
269
+ // update color count in percentage
265
270
  /__\d+(\.\d+)?%__/,
266
271
  `__${((colorsSrc.entires.length / (256 * 256 * 256)) * 100).toFixed(2)}%__`
272
+ ).replace(
273
+ // update file size
274
+ /\d+(\.\d+)? MB\)__/g,
275
+ `${
276
+ (fs.statSync(path.normalize(`${baseFolder}${folderDist}${fileNameSrc}.json`)).size / 1024 / 1024).toFixed(2)
277
+ } MB)__`
267
278
  ), 'utf8'
268
279
  );
269
280
 
@@ -3331,6 +3331,7 @@ Bold Bolection,#1d6575,
3331
3331
  Bold Brandy,#796660,
3332
3332
  Bold Brick,#8c5e55,
3333
3333
  Bold Eagle,#463d2f,
3334
+ Bold Gold,#ead56d,
3334
3335
  Bold Irish,#2a814d,x
3335
3336
  Bold Sangria,#7a4549,
3336
3337
  Bole,#79443b,
@@ -5319,7 +5320,7 @@ Chili Pepper,#ac1e3a,x
5319
5320
  Chili Sauce,#bc4e40,
5320
5321
  Chili Soda,#ca7c74,
5321
5322
  Chill in the Air,#d1d5e7,
5322
- Chill of Teamwork,#256d8d,
5323
+ Chill of the Night,#256d8d,x
5323
5324
  Chilled Chilly,#ec4236,
5324
5325
  Chilled Cucumber,#cbcdb2,
5325
5326
  Chilled Lemonade,#ffe696,
@@ -6426,6 +6427,7 @@ Cosmic Heart,#9601f4,x
6426
6427
  Cosmic Latte,#fff8e7,x
6427
6428
  Cosmic Quest,#9ea19f,
6428
6429
  Cosmic Ray,#cadada,
6430
+ Cosmic Red,#da244b,x
6429
6431
  Cosmic Sky,#aaaac4,
6430
6432
  Cosmic Void,#090533,
6431
6433
  Cosmo Purple,#a09bc6,
@@ -8065,6 +8067,7 @@ Dreamweaver,#ccc6d7,
8065
8067
  Dreamy Candy Forest,#b195e4,x
8066
8068
  Dreamy Cloud,#e5e6eb,
8067
8069
  Dreamy Heaven,#594158,
8070
+ Dreamy Memory,#e8c3d9,
8068
8071
  Dreamy Pink,#dfabcd,
8069
8072
  Dreamy Sunset,#ffad61,
8070
8073
  Dreamy White,#e3d8d5,
@@ -10466,6 +10469,7 @@ Galactic Emerald,#0afa1e,
10466
10469
  Galactic Federation,#330077,x
10467
10470
  Galactic Highway,#3311bb,x
10468
10471
  Galactic Mediator,#e0dfdb,
10472
+ Galactic Purple,#472e97,x
10469
10473
  Galactic Tint,#c0c4c6,
10470
10474
  Galactic Wonder,#442255,
10471
10475
  Galactica,#c4dde2,
@@ -14081,6 +14085,7 @@ Kiss Good Night,#e5c8d9,
14081
14085
  Kiss Me Kate,#e7eeec,
14082
14086
  Kiss Me More,#de6b86,x
14083
14087
  Kiss of a Vampire,#8a0009,x
14088
+ Kiss of Lime,#eae2ac,
14084
14089
  Kiss of the Scorpion,#dc331a,x
14085
14090
  Kissable,#fd8f79,x
14086
14091
  Kissed by a Zombies,#b15363,
@@ -14256,6 +14261,7 @@ Lady of the Sea,#0000cc,
14256
14261
  Lady Pink,#f3d2cf,
14257
14262
  Lady?S Cushions Pink,#c99bb0,
14258
14263
  Lady's Slipper,#e3e3ea,
14264
+ Ladybug,#bd474e,
14259
14265
  Ladylike,#ffc3bf,
14260
14266
  Laelia Pink,#f5c8dd,
14261
14267
  Lager,#f6f513,
@@ -14567,6 +14573,7 @@ Leek Powder,#b7b17a,
14567
14573
  Leek Soup,#7a9c58,
14568
14574
  Leek White,#cedcca,
14569
14575
  Leery Lemon,#f5c71a,
14576
+ Lees,#4c2226,
14570
14577
  Left on Red,#ff0303,x
14571
14578
  Legacy,#5e5a67,
14572
14579
  Legacy Blue,#9ec9e2,
@@ -15110,6 +15117,7 @@ Lilac Violet,#754a80,
15110
15117
  Lilacs in Spring,#e9cfe5,
15111
15118
  Lilas,#b4838f,
15112
15119
  Lilás,#cc99ff,
15120
+ Lili Elbe's Pink,#d4a1b0,
15113
15121
  Liliac,#c48efd,
15114
15122
  Lilliputian Lime,#88dd55,
15115
15123
  Lilting Laughter,#fcebd8,
@@ -15594,6 +15602,7 @@ Lunar Landing,#d2cfc1,x
15594
15602
  Lunar Launch Site,#938673,
15595
15603
  Lunar Light,#9b959c,x
15596
15604
  Lunar Lite,#e0ddd8,
15605
+ Lunar Luxury,#fbf4d6,x
15597
15606
  Lunar Outpost,#828287,x
15598
15607
  Lunar Rays,#caced2,
15599
15608
  Lunar Rock,#c5c5c5,
@@ -18187,6 +18196,7 @@ Nouveau Copper,#a05b42,
18187
18196
  Nouveau Rose,#996872,
18188
18197
  Nouveau-Riche,#ffbb77,x
18189
18198
  Nouvelle White,#e1dcda,
18199
+ Nova Pink,#d94f9a,
18190
18200
  Nova White,#f8eed9,
18191
18201
  Novel Lilac,#c2a4c2,x
18192
18202
  Novelle Peach,#e3c7b2,
@@ -20121,6 +20131,7 @@ Pinecone Path,#574745,
20121
20131
  Pinehurst,#2b7b66,
20122
20132
  Pinenut,#f8d9b8,
20123
20133
  Pinetop,#57593f,
20134
+ Pineweed,#5b7349,
20124
20135
  Piney Lake,#006655,
20125
20136
  Piney Wood,#70574f,
20126
20137
  Píng Gǔo Lǜ Green,#23c48b,
@@ -26091,6 +26102,7 @@ Sunkissed Yellow,#ffe9ba,
26091
26102
  Sunlight,#ebcd95,x
26092
26103
  Sunlit,#ffdb78,
26093
26104
  Sunlit Allium,#9787bb,
26105
+ Sunlit Glade,#98d4a0,
26094
26106
  Sunlit Kelp Green,#7d7103,
26095
26107
  Sunlounge,#da8433,
26096
26108
  Sunning Deck,#e8d7b1,
@@ -27620,9 +27632,10 @@ Turbinado Sugar,#f9bb59,
27620
27632
  Turbo,#f5cc23,
27621
27633
  Turbulence,#555c63,
27622
27634
  Turbulent Sea,#536a79,
27623
- Turf,#5f4f42,x
27635
+ Turf,#415b36,x
27624
27636
  Turf Green,#2a8948,
27625
27637
  Turf Master,#009922,x
27638
+ Turf War,#738050,
27626
27639
  Turkish Aqua,#006169,
27627
27640
  Turkish Bath,#bb937b,
27628
27641
  Turkish Blue,#007fae,
@@ -28997,6 +29010,7 @@ Whisper Blue,#e5e8f2,
28997
29010
  Whisper Green,#dce2d1,
28998
29011
  Whisper Grey,#e9e5da,
28999
29012
  Whisper of Grass,#cbede5,
29013
+ Whisper of Plum,#d4afda,
29000
29014
  Whisper of Rose,#cda2ac,
29001
29015
  Whisper of Smoke,#cbcecf,x
29002
29016
  Whisper of White,#eadbca,x
@@ -29173,7 +29187,6 @@ Wide Sky,#416faf,
29173
29187
  Widowmaker,#99aaff,x
29174
29188
  Wiener Dog,#874e3c,
29175
29189
  Wiener Schnitzel,#ee9900,
29176
- Wiggle,#c9c844,
29177
29190
  Wild Apple,#fef9d7,
29178
29191
  Wild Aster,#a53783,
29179
29192
  Wild Axolotl,#63775a,
@@ -1,120 +0,0 @@
1
- const lib = require('./lib.js');
2
- const ClosestVector = require('closestvector');
3
-
4
- /**
5
- * enriches color object and fills RGB color arrays
6
- * Warning: Not a pure function at all :D
7
- * @param {object} colorObj hex representation of color
8
- * @param {array} rgbColorArrRef reference to RGB color array
9
- * @return {object} enriched color object
10
- */
11
- const enrichColorObj = (colorObj, rgbColorArrRef) => {
12
- const rgb = lib.hexToRgb(colorObj.hex);
13
- // populates array needed for ClosestVector()
14
- rgbColorArrRef.push([rgb.r, rgb.g, rgb.b]);
15
- // transform hex to RGB
16
- colorObj.rgb = rgb;
17
- // get hsl color value
18
- colorObj.hsl = lib.rgbToHsl(...Object.values(rgb));
19
-
20
- // calculate luminancy for each color
21
- colorObj.luminance = lib.luminance(rgb);
22
-
23
- return colorObj;
24
- };
25
-
26
- module.exports = class FindColors {
27
- constructor(colorsListsObj) {
28
- this.colorLists = colorsListsObj;
29
-
30
- // object containing the name:hex pairs for nearestColor()
31
- this.colorListsRGBArrays = {};
32
- this.closestInstances = {};
33
-
34
- // prepare color array
35
- Object.keys(this.colorLists).forEach((listName) => {
36
- this.colorListsRGBArrays[listName] = [];
37
-
38
- this.colorLists[listName].forEach(c => {
39
- enrichColorObj(c, this.colorListsRGBArrays[listName]);
40
- });
41
-
42
- Object.freeze(this.colorLists[listName]);
43
- this.closestInstances[listName] = new ClosestVector(
44
- this.colorListsRGBArrays[listName]
45
- );
46
- });
47
- }
48
-
49
- _validateListKey (listKey) {
50
- if (!this.colorLists[listKey]) {
51
- throw new Error(`List key "${listKey}" is not valid.`);
52
- } else {
53
- return true;
54
- }
55
- }
56
-
57
- /**
58
- * returns all colors that match a name
59
- * @param {string} searchStr search term
60
- * @param {boolen} bestOf if set only returns good names
61
- */
62
- searchNames (searchStr, listKey = 'default') {
63
- this._validateListKey(listKey);
64
- return this.colorLists[listKey].filter(
65
- color => color.name.toLowerCase().includes(searchStr.toLowerCase())
66
- );
67
- }
68
-
69
- /**
70
- * names an array of colors
71
- * @param {array} colorArr array containing hex values without the hash
72
- * @param {boolean} unique if set to true every returned name will be unque
73
- * @param {boolean} bestOf if set only returns good names
74
- * @return {object} object containing all nearest colors
75
- */
76
- getNamesForValues(colorArr, unique = false, listKey = 'default') {
77
- let localClosest = this.closestInstances[listKey];
78
-
79
- if (unique) {
80
- localClosest = new ClosestVector(
81
- this.colorListsRGBArrays[listKey],
82
- true
83
- );
84
- }
85
-
86
- let lastResult = null;
87
-
88
- const colorResp = colorArr.map((hex) => {
89
- // calculate RGB values for passed color
90
- const rgb = lib.hexToRgb(hex);
91
-
92
- // get the closest named colors
93
- let closestColor = localClosest.get([rgb.r, rgb.g, rgb.b]);
94
- if (closestColor && unique) {
95
- lastResult = closestColor;
96
- } else if (unique) {
97
- closestColor = lastResult;
98
- }
99
- const color = this.colorLists[listKey][closestColor.index];
100
-
101
- return {
102
- ...color,
103
- requestedHex: `#${hex}`,
104
- distance: Math.sqrt(
105
- Math.pow(color.rgb.r - rgb.r, 2) +
106
- Math.pow(color.rgb.g - rgb.g, 2) +
107
- Math.pow(color.rgb.b - rgb.b, 2)
108
- ),
109
- }
110
- });
111
-
112
- if (unique) {
113
- localClosest.clearCache();
114
- }
115
-
116
- return colorResp;
117
- };
118
- }
119
-
120
-
@@ -1,48 +0,0 @@
1
- const seedrandom = require('seedrandom');
2
-
3
- /**
4
- * getPaletteTitle
5
- * @param {string[]} namesArr
6
- * @param {int(0-1)} rnd1
7
- * @param {int(0-1)} rnd2
8
- * @param {int(0-1)} longPartFirst
9
- * @param {RegExp} separatorRegex
10
- * @returns {string}
11
- */
12
-
13
- module.exports = function getPaletteTitle(
14
- namesArr, // array of names
15
- separatorRegex = /(\s|-)+/g
16
- ) {
17
- let localnames = [...namesArr];
18
-
19
- const rng = seedrandom(namesArr.join('-'));
20
- const rnd1 = rng();
21
- const rnd2 = rng();
22
- const longPartFirst = rng() < .5;
23
-
24
- // select a random name from the list for the first word in the palette title
25
- const indexFirst = Math.round(rnd1 * (localnames.length - 1));
26
-
27
- // remove the selected name from the list
28
- const firstName = localnames.splice(indexFirst, 1)[0];
29
-
30
- // select a random name from the list as a last word in the palette title
31
- const lastIndex = Math.round(rnd2 * (localnames.length - 1));
32
- const lastName = localnames[lastIndex];
33
-
34
- const partsFirst = firstName.split(separatorRegex);
35
- const partsLast = lastName.split(separatorRegex);
36
-
37
- if (longPartFirst) {
38
- partsFirst.length > 1 ?
39
- partsFirst.pop() :
40
- partsFirst[0] = `${partsFirst[0]} `;
41
- return partsFirst.join('') + partsLast.pop();
42
- } else {
43
- partsLast.length > 1 ?
44
- partsLast.shift() :
45
- partsLast[0] = ` ${partsLast[0]}`;
46
- return partsFirst.shift() + partsLast.join('');
47
- }
48
- }