color-name-list 9.8.0 → 9.10.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 +3 -3
- package/changes.svg +3 -3
- package/dist/colornames.bestof.csv +24 -0
- package/dist/colornames.bestof.esm.js +1 -1
- package/dist/colornames.bestof.esm.mjs +1 -1
- package/dist/colornames.bestof.html +1 -1
- package/dist/colornames.bestof.json +1 -1
- package/dist/colornames.bestof.min.json +1 -1
- package/dist/colornames.bestof.scss +1 -1
- package/dist/colornames.bestof.umd.js +1 -1
- package/dist/colornames.bestof.xml +96 -0
- package/dist/colornames.bestof.yaml +72 -0
- package/dist/colornames.csv +41 -1
- package/dist/colornames.esm.js +1 -1
- package/dist/colornames.esm.mjs +1 -1
- package/dist/colornames.html +1 -1
- package/dist/colornames.json +1 -1
- package/dist/colornames.min.json +1 -1
- package/dist/colornames.scss +1 -1
- package/dist/colornames.umd.js +1 -1
- package/dist/colornames.xml +161 -1
- package/dist/colornames.yaml +121 -1
- package/package.json +3 -1
- package/scripts/findColors.js +40 -22
- package/scripts/generatePaletteName.js +48 -0
- package/scripts/server.js +135 -34
- package/scripts/tools/filterUniques.js +13 -11
- package/src/colornames.csv +41 -1
package/dist/colornames.yaml
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
hex:"#e56e24"
|
|
19
19
|
-
|
|
20
20
|
name:"24 Karat"
|
|
21
|
-
hex:"#
|
|
21
|
+
hex:"#dfc685"
|
|
22
22
|
-
|
|
23
23
|
name:"3AM in Shibuya"
|
|
24
24
|
hex:"#225577"
|
|
@@ -238,6 +238,9 @@
|
|
|
238
238
|
-
|
|
239
239
|
name:"Acapulco"
|
|
240
240
|
hex:"#75aa94"
|
|
241
|
+
-
|
|
242
|
+
name:"Acapulco Aqua"
|
|
243
|
+
hex:"#7fa8a7"
|
|
241
244
|
-
|
|
242
245
|
name:"Acapulco Cliffs"
|
|
243
246
|
hex:"#4e9aa8"
|
|
@@ -802,6 +805,9 @@
|
|
|
802
805
|
-
|
|
803
806
|
name:"Air Superiority Blue"
|
|
804
807
|
hex:"#72a0c1"
|
|
808
|
+
-
|
|
809
|
+
name:"Air-Kiss"
|
|
810
|
+
hex:"#f6dcd2"
|
|
805
811
|
-
|
|
806
812
|
name:"Airborne"
|
|
807
813
|
hex:"#a2c2d0"
|
|
@@ -829,6 +835,9 @@
|
|
|
829
835
|
-
|
|
830
836
|
name:"Airline Green"
|
|
831
837
|
hex:"#8c9632"
|
|
838
|
+
-
|
|
839
|
+
name:"Airway"
|
|
840
|
+
hex:"#aec1d4"
|
|
832
841
|
-
|
|
833
842
|
name:"Airy"
|
|
834
843
|
hex:"#dae6e9"
|
|
@@ -919,6 +928,9 @@
|
|
|
919
928
|
-
|
|
920
929
|
name:"Alarming Slime"
|
|
921
930
|
hex:"#2ce335"
|
|
931
|
+
-
|
|
932
|
+
name:"Alaska"
|
|
933
|
+
hex:"#dadad1"
|
|
922
934
|
-
|
|
923
935
|
name:"Alaskan Blue"
|
|
924
936
|
hex:"#6da9d2"
|
|
@@ -1753,6 +1765,9 @@
|
|
|
1753
1765
|
-
|
|
1754
1766
|
name:"Ambrosia Salad"
|
|
1755
1767
|
hex:"#f4ded3"
|
|
1768
|
+
-
|
|
1769
|
+
name:"Ambrosial Oceanside"
|
|
1770
|
+
hex:"#47ae9c"
|
|
1756
1771
|
-
|
|
1757
1772
|
name:"Ameixa"
|
|
1758
1773
|
hex:"#6a5acd"
|
|
@@ -3211,6 +3226,9 @@
|
|
|
3211
3226
|
-
|
|
3212
3227
|
name:"Aquatic Cool"
|
|
3213
3228
|
hex:"#41a0b4"
|
|
3229
|
+
-
|
|
3230
|
+
name:"Aquatic Edge"
|
|
3231
|
+
hex:"#bfd6d1"
|
|
3214
3232
|
-
|
|
3215
3233
|
name:"Aquatic Green"
|
|
3216
3234
|
hex:"#49999a"
|
|
@@ -3295,6 +3313,9 @@
|
|
|
3295
3313
|
-
|
|
3296
3314
|
name:"Arame Seaweed Green"
|
|
3297
3315
|
hex:"#3f4635"
|
|
3316
|
+
-
|
|
3317
|
+
name:"Arancio"
|
|
3318
|
+
hex:"#ff7013"
|
|
3298
3319
|
-
|
|
3299
3320
|
name:"Arapawa"
|
|
3300
3321
|
hex:"#274a5d"
|
|
@@ -3721,6 +3742,9 @@
|
|
|
3721
3742
|
-
|
|
3722
3743
|
name:"Artichoke Green"
|
|
3723
3744
|
hex:"#4b6d41"
|
|
3745
|
+
-
|
|
3746
|
+
name:"Artichoke Heart"
|
|
3747
|
+
hex:"#e4d588"
|
|
3724
3748
|
-
|
|
3725
3749
|
name:"Artichoke Mauve"
|
|
3726
3750
|
hex:"#c19aa5"
|
|
@@ -4627,6 +4651,9 @@
|
|
|
4627
4651
|
-
|
|
4628
4652
|
name:"Avocado Whip"
|
|
4629
4653
|
hex:"#cdd6b1"
|
|
4654
|
+
-
|
|
4655
|
+
name:"Avorio"
|
|
4656
|
+
hex:"#ccbdb4"
|
|
4630
4657
|
-
|
|
4631
4658
|
name:"Awaken"
|
|
4632
4659
|
hex:"#a7a3bb"
|
|
@@ -4696,6 +4723,9 @@
|
|
|
4696
4723
|
-
|
|
4697
4724
|
name:"Azeitona"
|
|
4698
4725
|
hex:"#a5b546"
|
|
4726
|
+
-
|
|
4727
|
+
name:"Azores"
|
|
4728
|
+
hex:"#7c968b"
|
|
4699
4729
|
-
|
|
4700
4730
|
name:"Azores Blue"
|
|
4701
4731
|
hex:"#0085a7"
|
|
@@ -4714,6 +4744,9 @@
|
|
|
4714
4744
|
-
|
|
4715
4745
|
name:"Aztec Brick"
|
|
4716
4746
|
hex:"#9e8352"
|
|
4747
|
+
-
|
|
4748
|
+
name:"Aztec Copper"
|
|
4749
|
+
hex:"#c46943"
|
|
4717
4750
|
-
|
|
4718
4751
|
name:"Aztec Glimmer"
|
|
4719
4752
|
hex:"#e7b347"
|
|
@@ -4765,6 +4798,9 @@
|
|
|
4765
4798
|
-
|
|
4766
4799
|
name:"Azul Turquesa"
|
|
4767
4800
|
hex:"#6abac4"
|
|
4801
|
+
-
|
|
4802
|
+
name:"Azulado"
|
|
4803
|
+
hex:"#211d49"
|
|
4768
4804
|
-
|
|
4769
4805
|
name:"Azure"
|
|
4770
4806
|
hex:"#007fff"
|
|
@@ -5284,6 +5320,9 @@
|
|
|
5284
5320
|
-
|
|
5285
5321
|
name:"Balsamic Reduction"
|
|
5286
5322
|
hex:"#434340"
|
|
5323
|
+
-
|
|
5324
|
+
name:"Balsamico"
|
|
5325
|
+
hex:"#130d07"
|
|
5287
5326
|
-
|
|
5288
5327
|
name:"Balthasar Gold"
|
|
5289
5328
|
hex:"#a47552"
|
|
@@ -8134,6 +8173,9 @@
|
|
|
8134
8173
|
-
|
|
8135
8174
|
name:"Blizzard Blue"
|
|
8136
8175
|
hex:"#a3e3ed"
|
|
8176
|
+
-
|
|
8177
|
+
name:"Blizzy Blueberry"
|
|
8178
|
+
hex:"#1151b4"
|
|
8137
8179
|
-
|
|
8138
8180
|
name:"Blobfish"
|
|
8139
8181
|
hex:"#ffc1cc"
|
|
@@ -13117,6 +13159,9 @@
|
|
|
13117
13159
|
-
|
|
13118
13160
|
name:"Canoe Blue"
|
|
13119
13161
|
hex:"#1d5671"
|
|
13162
|
+
-
|
|
13163
|
+
name:"Canola Oil"
|
|
13164
|
+
hex:"#f7eb7a"
|
|
13120
13165
|
-
|
|
13121
13166
|
name:"Canopy"
|
|
13122
13167
|
hex:"#728f02"
|
|
@@ -20923,6 +20968,9 @@
|
|
|
20923
20968
|
-
|
|
20924
20969
|
name:"Dark Cherry Mocha"
|
|
20925
20970
|
hex:"#774d41"
|
|
20971
|
+
-
|
|
20972
|
+
name:"Dark Chocolate"
|
|
20973
|
+
hex:"#624a49"
|
|
20926
20974
|
-
|
|
20927
20975
|
name:"Dark Citron"
|
|
20928
20976
|
hex:"#aabb00"
|
|
@@ -20950,6 +20998,9 @@
|
|
|
20950
20998
|
-
|
|
20951
20999
|
name:"Dark Denim Blue"
|
|
20952
21000
|
hex:"#00334f"
|
|
21001
|
+
-
|
|
21002
|
+
name:"Dark Drama"
|
|
21003
|
+
hex:"#5a3939"
|
|
20953
21004
|
-
|
|
20954
21005
|
name:"Dark Dreams"
|
|
20955
21006
|
hex:"#332266"
|
|
@@ -36892,6 +36943,9 @@
|
|
|
36892
36943
|
-
|
|
36893
36944
|
name:"Highlander"
|
|
36894
36945
|
hex:"#3a533d"
|
|
36946
|
+
-
|
|
36947
|
+
name:"Highlands"
|
|
36948
|
+
hex:"#449084"
|
|
36895
36949
|
-
|
|
36896
36950
|
name:"Highlands Moss"
|
|
36897
36951
|
hex:"#445500"
|
|
@@ -36946,6 +37000,9 @@
|
|
|
36946
37000
|
-
|
|
36947
37001
|
name:"Hiker's Delight"
|
|
36948
37002
|
hex:"#d2b395"
|
|
37003
|
+
-
|
|
37004
|
+
name:"Hiking"
|
|
37005
|
+
hex:"#9d9866"
|
|
36949
37006
|
-
|
|
36950
37007
|
name:"Hiking Boots"
|
|
36951
37008
|
hex:"#5e5440"
|
|
@@ -37444,6 +37501,9 @@
|
|
|
37444
37501
|
-
|
|
37445
37502
|
name:"Honey Ginger"
|
|
37446
37503
|
hex:"#a86217"
|
|
37504
|
+
-
|
|
37505
|
+
name:"Honey Glaze"
|
|
37506
|
+
hex:"#ffd775"
|
|
37447
37507
|
-
|
|
37448
37508
|
name:"Honey Glow"
|
|
37449
37509
|
hex:"#e8b447"
|
|
@@ -38803,6 +38863,9 @@
|
|
|
38803
38863
|
-
|
|
38804
38864
|
name:"In the Buff"
|
|
38805
38865
|
hex:"#d6cbbf"
|
|
38866
|
+
-
|
|
38867
|
+
name:"In the Dark"
|
|
38868
|
+
hex:"#3b3c41"
|
|
38806
38869
|
-
|
|
38807
38870
|
name:"In the Hills"
|
|
38808
38871
|
hex:"#aea69b"
|
|
@@ -40108,6 +40171,9 @@
|
|
|
40108
40171
|
-
|
|
40109
40172
|
name:"Jade Mussel Green"
|
|
40110
40173
|
hex:"#166a45"
|
|
40174
|
+
-
|
|
40175
|
+
name:"Jade of Emeralds"
|
|
40176
|
+
hex:"#318f33"
|
|
40111
40177
|
-
|
|
40112
40178
|
name:"Jade Orchid"
|
|
40113
40179
|
hex:"#00aaaa"
|
|
@@ -44923,6 +44989,9 @@
|
|
|
44923
44989
|
-
|
|
44924
44990
|
name:"Lingering Lilac"
|
|
44925
44991
|
hex:"#e6def0"
|
|
44992
|
+
-
|
|
44993
|
+
name:"Lingering Storm"
|
|
44994
|
+
hex:"#858381"
|
|
44926
44995
|
-
|
|
44927
44996
|
name:"Lingonberry"
|
|
44928
44997
|
hex:"#ff255c"
|
|
@@ -49120,6 +49189,9 @@
|
|
|
49120
49189
|
-
|
|
49121
49190
|
name:"Midnight Serenade"
|
|
49122
49191
|
hex:"#41434e"
|
|
49192
|
+
-
|
|
49193
|
+
name:"Midnight Shadow"
|
|
49194
|
+
hex:"#566373"
|
|
49123
49195
|
-
|
|
49124
49196
|
name:"Midnight Show"
|
|
49125
49197
|
hex:"#546473"
|
|
@@ -64246,6 +64318,9 @@
|
|
|
64246
64318
|
-
|
|
64247
64319
|
name:"Rè Dài Chéng Orange"
|
|
64248
64320
|
hex:"#f08101"
|
|
64321
|
+
-
|
|
64322
|
+
name:"Re-Entry Red"
|
|
64323
|
+
hex:"#cd0317"
|
|
64249
64324
|
-
|
|
64250
64325
|
name:"Reading Tea Leaves"
|
|
64251
64326
|
hex:"#7d5d5e"
|
|
@@ -76846,6 +76921,9 @@
|
|
|
76846
76921
|
-
|
|
76847
76922
|
name:"Sunbathed"
|
|
76848
76923
|
hex:"#f5dd98"
|
|
76924
|
+
-
|
|
76925
|
+
name:"Sunbathed Beach"
|
|
76926
|
+
hex:"#fad28f"
|
|
76849
76927
|
-
|
|
76850
76928
|
name:"Sunbathing Beauty"
|
|
76851
76929
|
hex:"#7e4730"
|
|
@@ -80095,6 +80173,9 @@
|
|
|
80095
80173
|
-
|
|
80096
80174
|
name:"Toasted Oatmeal"
|
|
80097
80175
|
hex:"#efdecc"
|
|
80176
|
+
-
|
|
80177
|
+
name:"Toasted Paprika"
|
|
80178
|
+
hex:"#a34631"
|
|
80098
80179
|
-
|
|
80099
80180
|
name:"Toasted Pecan"
|
|
80100
80181
|
hex:"#765143"
|
|
@@ -85315,6 +85396,9 @@
|
|
|
85315
85396
|
-
|
|
85316
85397
|
name:"Where Buffalo Roam"
|
|
85317
85398
|
hex:"#c19851"
|
|
85399
|
+
-
|
|
85400
|
+
name:"Where There Is Smoke"
|
|
85401
|
+
hex:"#c7ccce"
|
|
85318
85402
|
-
|
|
85319
85403
|
name:"Whero Red"
|
|
85320
85404
|
hex:"#dd262b"
|
|
@@ -86290,6 +86374,9 @@
|
|
|
86290
86374
|
-
|
|
86291
86375
|
name:"Wind Chill"
|
|
86292
86376
|
hex:"#eff3f0"
|
|
86377
|
+
-
|
|
86378
|
+
name:"Wind Chime"
|
|
86379
|
+
hex:"#dfe0e2"
|
|
86293
86380
|
-
|
|
86294
86381
|
name:"Wind Chimes"
|
|
86295
86382
|
hex:"#cac5c2"
|
|
@@ -86425,6 +86512,9 @@
|
|
|
86425
86512
|
-
|
|
86426
86513
|
name:"Windsurfer"
|
|
86427
86514
|
hex:"#d7e2de"
|
|
86515
|
+
-
|
|
86516
|
+
name:"Windsurfing"
|
|
86517
|
+
hex:"#3a7099"
|
|
86428
86518
|
-
|
|
86429
86519
|
name:"Windswept"
|
|
86430
86520
|
hex:"#d1f1f5"
|
|
@@ -86440,6 +86530,9 @@
|
|
|
86440
86530
|
-
|
|
86441
86531
|
name:"Windwood Spring"
|
|
86442
86532
|
hex:"#c2e5e0"
|
|
86533
|
+
-
|
|
86534
|
+
name:"Windy"
|
|
86535
|
+
hex:"#bdd1d2"
|
|
86443
86536
|
-
|
|
86444
86537
|
name:"Windy Blue"
|
|
86445
86538
|
hex:"#aabac6"
|
|
@@ -86980,6 +87073,9 @@
|
|
|
86980
87073
|
-
|
|
86981
87074
|
name:"Wistman's Wood"
|
|
86982
87075
|
hex:"#aa9966"
|
|
87076
|
+
-
|
|
87077
|
+
name:"Witch Brew"
|
|
87078
|
+
hex:"#888738"
|
|
86983
87079
|
-
|
|
86984
87080
|
name:"Witch Hazel"
|
|
86985
87081
|
hex:"#fbf073"
|
|
@@ -87043,6 +87139,9 @@
|
|
|
87043
87139
|
-
|
|
87044
87140
|
name:"Wizard's Spell"
|
|
87045
87141
|
hex:"#584b4e"
|
|
87142
|
+
-
|
|
87143
|
+
name:"Wizards Orb"
|
|
87144
|
+
hex:"#007c76"
|
|
87046
87145
|
-
|
|
87047
87146
|
name:"Woad Blue"
|
|
87048
87147
|
hex:"#597fb9"
|
|
@@ -87055,6 +87154,9 @@
|
|
|
87055
87154
|
-
|
|
87056
87155
|
name:"Wobbegong Brown"
|
|
87057
87156
|
hex:"#c19a6b"
|
|
87157
|
+
-
|
|
87158
|
+
name:"Wolf"
|
|
87159
|
+
hex:"#788389"
|
|
87058
87160
|
-
|
|
87059
87161
|
name:"Wolf Lichen"
|
|
87060
87162
|
hex:"#a8ff04"
|
|
@@ -87211,6 +87313,9 @@
|
|
|
87211
87313
|
-
|
|
87212
87314
|
name:"Woodland Moss"
|
|
87213
87315
|
hex:"#5c645c"
|
|
87316
|
+
-
|
|
87317
|
+
name:"Woodland Night"
|
|
87318
|
+
hex:"#475c5d"
|
|
87214
87319
|
-
|
|
87215
87320
|
name:"Woodland Nymph"
|
|
87216
87321
|
hex:"#69804b"
|
|
@@ -87241,6 +87346,9 @@
|
|
|
87241
87346
|
-
|
|
87242
87347
|
name:"Woodsmoke"
|
|
87243
87348
|
hex:"#2b3230"
|
|
87349
|
+
-
|
|
87350
|
+
name:"Woodstock"
|
|
87351
|
+
hex:"#9b8a5f"
|
|
87244
87352
|
-
|
|
87245
87353
|
name:"Woodstock Rose"
|
|
87246
87354
|
hex:"#e9cab6"
|
|
@@ -87370,6 +87478,9 @@
|
|
|
87370
87478
|
-
|
|
87371
87479
|
name:"Wrack White"
|
|
87372
87480
|
hex:"#ecead0"
|
|
87481
|
+
-
|
|
87482
|
+
name:"Wrapped in Twilight"
|
|
87483
|
+
hex:"#5f6d6e"
|
|
87373
87484
|
-
|
|
87374
87485
|
name:"Wreath"
|
|
87375
87486
|
hex:"#76856a"
|
|
@@ -87658,6 +87769,9 @@
|
|
|
87658
87769
|
-
|
|
87659
87770
|
name:"Yellow Mask"
|
|
87660
87771
|
hex:"#f6d255"
|
|
87772
|
+
-
|
|
87773
|
+
name:"Yellow Mellow"
|
|
87774
|
+
hex:"#f0d31e"
|
|
87661
87775
|
-
|
|
87662
87776
|
name:"Yellow Metal"
|
|
87663
87777
|
hex:"#73633e"
|
|
@@ -87814,6 +87928,12 @@
|
|
|
87814
87928
|
-
|
|
87815
87929
|
name:"Yeti Footprint"
|
|
87816
87930
|
hex:"#c7d7e0"
|
|
87931
|
+
-
|
|
87932
|
+
name:"Yew"
|
|
87933
|
+
hex:"#abbc01"
|
|
87934
|
+
-
|
|
87935
|
+
name:"Yew Hedge"
|
|
87936
|
+
hex:"#656952"
|
|
87817
87937
|
-
|
|
87818
87938
|
name:"Yín Bái Silver"
|
|
87819
87939
|
hex:"#e0e1e2"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "color-name-list",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.10.0",
|
|
4
4
|
"description": "long list of color names",
|
|
5
5
|
"main": "dist/colornames.json",
|
|
6
6
|
"browser": "dist/colornames.umd.js",
|
|
@@ -33,10 +33,12 @@
|
|
|
33
33
|
"homepage": "https://github.com/meodai/color-names#readme",
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"closestvector": "^0.6.0",
|
|
36
|
+
"color-name-lists": "^2.1.0",
|
|
36
37
|
"commitizen": "^4.2.4",
|
|
37
38
|
"eslint": "^5.15.1",
|
|
38
39
|
"eslint-config-google": "^0.10.0",
|
|
39
40
|
"ghooks": "^2.0.4",
|
|
41
|
+
"seedrandom": "^3.0.5",
|
|
40
42
|
"semantic-release": "^17.4.2"
|
|
41
43
|
},
|
|
42
44
|
"engines": {
|
package/scripts/findColors.js
CHANGED
|
@@ -2,7 +2,7 @@ const lib = require('./lib.js');
|
|
|
2
2
|
const ClosestVector = require('closestvector');
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* enriches color object and fills RGB color arrays
|
|
6
6
|
* Warning: Not a pure function at all :D
|
|
7
7
|
* @param {object} colorObj hex representation of color
|
|
8
8
|
* @param {array} rgbColorArrRef reference to RGB color array
|
|
@@ -24,24 +24,34 @@ const enrichColorObj = (colorObj, rgbColorArrRef) => {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
module.exports = class FindColors {
|
|
27
|
-
constructor(
|
|
28
|
-
|
|
29
|
-
this.colors = colors;
|
|
30
|
-
this.colorsBestOf = colorsBestOf;
|
|
27
|
+
constructor(colorsListsObj) {
|
|
28
|
+
this.colorLists = colorsListsObj;
|
|
31
29
|
|
|
32
30
|
// object containing the name:hex pairs for nearestColor()
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
31
|
+
this.colorListsRGBArrays = {};
|
|
32
|
+
this.closestInstances = {};
|
|
35
33
|
|
|
36
34
|
// prepare color array
|
|
37
|
-
this.
|
|
38
|
-
|
|
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
|
+
});
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
Object.freeze(this.colorLists[listName]);
|
|
43
|
+
this.closestInstances[listName] = new ClosestVector(
|
|
44
|
+
this.colorListsRGBArrays[listName]
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
42
48
|
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
_validateListKey (listKey) {
|
|
50
|
+
if (!this.colorLists[listKey]) {
|
|
51
|
+
throw new Error(`List key "${listKey}" is not valid.`);
|
|
52
|
+
} else {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
/**
|
|
@@ -49,9 +59,11 @@ module.exports = class FindColors {
|
|
|
49
59
|
* @param {string} searchStr search term
|
|
50
60
|
* @param {boolen} bestOf if set only returns good names
|
|
51
61
|
*/
|
|
52
|
-
searchNames (searchStr,
|
|
53
|
-
|
|
54
|
-
return
|
|
62
|
+
searchNames (searchStr, listKey = 'default') {
|
|
63
|
+
this._validateListKey(listKey);
|
|
64
|
+
return this.colorLists[listKey].filter(
|
|
65
|
+
color => color.name.toLowerCase().includes(searchStr.toLowerCase())
|
|
66
|
+
);
|
|
55
67
|
}
|
|
56
68
|
|
|
57
69
|
/**
|
|
@@ -61,24 +73,30 @@ module.exports = class FindColors {
|
|
|
61
73
|
* @param {boolean} bestOf if set only returns good names
|
|
62
74
|
* @return {object} object containing all nearest colors
|
|
63
75
|
*/
|
|
64
|
-
getNamesForValues
|
|
65
|
-
let localClosest =
|
|
76
|
+
getNamesForValues(colorArr, unique = false, listKey = 'default') {
|
|
77
|
+
let localClosest = this.closestInstances[listKey];
|
|
66
78
|
|
|
67
79
|
if (unique) {
|
|
68
80
|
localClosest = new ClosestVector(
|
|
69
|
-
|
|
81
|
+
this.colorListsRGBArrays[listKey],
|
|
70
82
|
true
|
|
71
83
|
);
|
|
72
84
|
}
|
|
73
85
|
|
|
86
|
+
let lastResult = null;
|
|
87
|
+
|
|
74
88
|
const colorResp = colorArr.map((hex) => {
|
|
75
89
|
// calculate RGB values for passed color
|
|
76
90
|
const rgb = lib.hexToRgb(hex);
|
|
77
91
|
|
|
78
92
|
// get the closest named colors
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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];
|
|
82
100
|
|
|
83
101
|
return {
|
|
84
102
|
...color,
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|