@studiotoolkit/color-palette-generator 1.0.0 → 1.0.1
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/dist/index.js +2 -4
- package/dist/index.mjs +1564 -1389
- package/package.json +8 -7
package/dist/index.mjs
CHANGED
|
@@ -1,1391 +1,1566 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}),
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
}),
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
})
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
},
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
},
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
},
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
},
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
},
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
},
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
},
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1
|
+
// src/generators/AlgorithmicGenerator.ts
|
|
2
|
+
var e = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, t = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, n = (e) => Math.max(0, Math.min(1, e)), r = (e, t, n) => e + (t - e) * n, i = Math.PI * 2, a = ({ r: t, g: n, b: r }) => {
|
|
3
|
+
let i = e(t), a = e(n), o = e(r), s = Math.cbrt(.4122214708 * i + .5363325363 * a + .0514459929 * o), c = Math.cbrt(.2119034982 * i + .6806995451 * a + .1073969566 * o), l = Math.cbrt(.0883024619 * i + .2817188376 * a + .6299787005 * o);
|
|
4
|
+
return {
|
|
5
|
+
L: .2104542553 * s + .793617785 * c - .0040720468 * l,
|
|
6
|
+
a: 1.9779984951 * s - 2.428592205 * c + .4505937099 * l,
|
|
7
|
+
b: .0259040371 * s + .7827717662 * c - .808675766 * l
|
|
8
|
+
};
|
|
9
|
+
}, o = ({ L: e, a: r, b: i }) => {
|
|
10
|
+
let a = e + .3963377774 * r + .2158037573 * i, o = e - .1055613458 * r - .0638541728 * i, s = e - .0894841775 * r - 1.291485548 * i, c = a * a * a, l = o * o * o, u = s * s * s;
|
|
11
|
+
return {
|
|
12
|
+
r: n(t(4.0767416621 * c - 3.3077115913 * l + .2309699292 * u)),
|
|
13
|
+
g: n(t(-1.2684380046 * c + 2.6097574011 * l - .3413193965 * u)),
|
|
14
|
+
b: n(t(-.0041960863 * c - .7034186147 * l + 1.707614701 * u))
|
|
15
|
+
};
|
|
16
|
+
}, s = ({ L: e, a: t, b: n }) => ({
|
|
17
|
+
L: e,
|
|
18
|
+
C: Math.sqrt(t * t + n * n),
|
|
19
|
+
H: (Math.atan2(n, t) * 180 / Math.PI + 360) % 360
|
|
20
|
+
}), c = ({ L: e, C: t, H: n }) => ({
|
|
21
|
+
L: e,
|
|
22
|
+
a: t * Math.cos(n * Math.PI / 180),
|
|
23
|
+
b: t * Math.sin(n * Math.PI / 180)
|
|
24
|
+
}), l = (e) => ({
|
|
25
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
26
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
27
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
28
|
+
}), u = ({ r: e, g: t, b: n }) => {
|
|
29
|
+
let r = (e) => Math.round(e * 255).toString(16).padStart(2, "0");
|
|
30
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
31
|
+
}, d = (e) => s(a(l(e))), f = (e) => u(o(c(e))), p = (e) => u(o(e)), m = (e, t, n) => ({
|
|
32
|
+
L: r(e.L, t.L, n),
|
|
33
|
+
a: r(e.a, t.a, n),
|
|
34
|
+
b: r(e.b, t.b, n)
|
|
35
|
+
}), ee = (e) => {
|
|
36
|
+
let t = e >>> 0;
|
|
37
|
+
return () => {
|
|
38
|
+
t += 1831565813;
|
|
39
|
+
let e = t;
|
|
40
|
+
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
|
|
41
|
+
};
|
|
42
|
+
}, h = (e) => {
|
|
43
|
+
let t = 0;
|
|
44
|
+
for (let n = 1; n < 7; n++) t = Math.imul(31, t) + parseInt(e[n], 16) | 0;
|
|
45
|
+
return Math.abs(t);
|
|
46
|
+
}, g = (e) => {
|
|
47
|
+
let t = [], n = ee(e);
|
|
48
|
+
for (let e = 0; e < 256; e++) t.push(n());
|
|
49
|
+
let i = (e) => e * e * (3 - 2 * e);
|
|
50
|
+
return (e) => {
|
|
51
|
+
let n = Math.floor(e) & 255, a = e - Math.floor(e);
|
|
52
|
+
return r(t[n], t[n + 1 & 255], i(a));
|
|
53
|
+
};
|
|
54
|
+
}, _ = (e, t, n, r, i) => {
|
|
55
|
+
let a = 1 - i;
|
|
56
|
+
return a * a * a * e + 3 * a * a * i * t + 3 * a * i * i * n + i * i * i * r;
|
|
57
|
+
}, v = (e, t, n, r, i) => ({
|
|
58
|
+
L: _(e.L, t.L, n.L, r.L, i),
|
|
59
|
+
a: _(e.a, t.a, n.a, r.a, i),
|
|
60
|
+
b: _(e.b, e.b, n.b, r.b, i)
|
|
61
|
+
}), te = (e) => e < .5 ? 4 * e * e * e : 1 - (-2 * e + 2) ** 3 / 2, ne = (e) => {
|
|
62
|
+
let r;
|
|
63
|
+
r = e >= 1667 && e <= 4e3 ? -266123900 / (e * e * e) - 234358 / (e * e) + 877.6956 / e + .17991 : -3025846900 / (e * e * e) + 2107037.9 / (e * e) + 222.6347 / e + .24039;
|
|
64
|
+
let i;
|
|
65
|
+
i = e >= 1667 && e <= 2222 ? -1.1063814 * r * r * r - 1.3481102 * r * r + 2.18555832 * r - .20219683 : e <= 4e3 ? -.9549476 * r * r * r - 1.37418593 * r * r + 2.09137015 * r - .16748867 : 3.081758 * r * r * r - 5.8733867 * r * r + 3.75112997 * r - .37001483;
|
|
66
|
+
let a = 1 * r / Math.max(i, 1e-6), o = 1 * (1 - r - i) / Math.max(i, 1e-6), s = 3.2406 * a - 1.5372 - .4986 * o, c = -.9689 * a + 1.8758 + .0415 * o, l = .0557 * a - .204 + 1.057 * o, u = Math.max(s, c, l, 1e-6);
|
|
67
|
+
return {
|
|
68
|
+
r: n(t(s / u)),
|
|
69
|
+
g: n(t(c / u)),
|
|
70
|
+
b: n(t(l / u))
|
|
71
|
+
};
|
|
72
|
+
}, re = (e, t = .5, r = -1.5, a = 1.2, o = 1) => {
|
|
73
|
+
let s = i * (t / 3 + r * e), c = e ** +o, l = a * c * (1 - c) / 2, u = Math.cos(s), d = Math.sin(s);
|
|
74
|
+
return {
|
|
75
|
+
r: n(c + l * (-.14861 * u + 1.78277 * d)),
|
|
76
|
+
g: n(c + l * (-.29227 * u - .90649 * d)),
|
|
77
|
+
b: n(c + 1.97294 * u * l)
|
|
78
|
+
};
|
|
79
|
+
}, ie = (e, t) => {
|
|
80
|
+
let n = ee(h(e));
|
|
81
|
+
return Array.from({ length: t }, () => f({
|
|
82
|
+
L: r(.35, .75, n()),
|
|
83
|
+
C: r(.08, .2, n()),
|
|
84
|
+
H: n() * 360
|
|
85
|
+
}));
|
|
86
|
+
}, ae = (e, t) => {
|
|
87
|
+
let n = d(e);
|
|
88
|
+
return Array.from({ length: t }, (e, t) => {
|
|
89
|
+
let i = (n.H + 137.50776405003785 * t) % 360;
|
|
90
|
+
return f({
|
|
91
|
+
L: r(.45, .7, t % 3 / 2),
|
|
92
|
+
C: Math.max(n.C, .1),
|
|
93
|
+
H: i
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
}, oe = (e, t) => {
|
|
97
|
+
let i = d(e), a = h(e), o = g(a), s = g(a + 1), c = g(a + 2);
|
|
98
|
+
return Array.from({ length: t }, (e, a) => {
|
|
99
|
+
let l = a / Math.max(t - 1, 1);
|
|
100
|
+
return f({
|
|
101
|
+
L: n(r(.35, .8, o(l * 3.5))),
|
|
102
|
+
C: n(r(.06, .22, s(l * 4.1 + 1))),
|
|
103
|
+
H: (i.H + c(l * 2.7 + 2) * 120 - 60) % 360
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}, se = (e, t) => {
|
|
107
|
+
let n = (d(e).H - 120 + 360) % 360;
|
|
108
|
+
return Array.from({ length: t }, (e, i) => {
|
|
109
|
+
let a = i / (t - 1), o = (r(20, 220, a) + n) % 360;
|
|
110
|
+
return f({
|
|
111
|
+
L: .35 + .45 * Math.sin(a * Math.PI),
|
|
112
|
+
C: r(.18, .12, Math.abs(a - .5) * 2),
|
|
113
|
+
H: o
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
}, ce = (e, t) => {
|
|
117
|
+
let n = e.slice(0, 4).map((e) => a(l(e)));
|
|
118
|
+
for (; n.length < 4;) n.push({ ...n[n.length - 1] });
|
|
119
|
+
let r = {
|
|
120
|
+
L: (n[0].L + n[3].L) / 2,
|
|
121
|
+
a: (n[0].a + n[3].a) / 2,
|
|
122
|
+
b: (n[0].b + n[3].b) / 2
|
|
123
|
+
};
|
|
124
|
+
return n[1] = m(n[1], r, .35), n[2] = m(n[2], r, .35), Array.from({ length: t }, (e, r) => {
|
|
125
|
+
let i = r / (t - 1);
|
|
126
|
+
return p(v(n[0], n[1], n[2], n[3], i));
|
|
127
|
+
});
|
|
128
|
+
}, le = (e, t) => {
|
|
129
|
+
let n = d(e);
|
|
130
|
+
return Array.from({ length: t }, (e, i) => {
|
|
131
|
+
let a = i / (t - 1);
|
|
132
|
+
return f({
|
|
133
|
+
L: r(.28, .88, te(a)),
|
|
134
|
+
C: n.C * (1 - .4 * Math.abs(a - .5) * 2),
|
|
135
|
+
H: n.H
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
}, ue = (e, t) => {
|
|
139
|
+
let n = d(e).H / 360 * 3e3, i = Math.max(900, 1500 + n), a = Math.min(15e3, 9e3 + n);
|
|
140
|
+
return Array.from({ length: t }, (e, n) => {
|
|
141
|
+
let o = n / (t - 1);
|
|
142
|
+
return u(ne(r(i, a, o)));
|
|
143
|
+
});
|
|
144
|
+
}, de = (e, t) => {
|
|
145
|
+
let n = d(e), i = [1, 1];
|
|
146
|
+
for (; i.length < t;) i.push(i[i.length - 1] + i[i.length - 2]);
|
|
147
|
+
return Array.from({ length: t }, (e, t) => {
|
|
148
|
+
let a = (n.H + i[t] * 47 % 360) % 360;
|
|
149
|
+
return f({
|
|
150
|
+
L: r(.4, .72, t % 4 / 3),
|
|
151
|
+
C: Math.max(n.C, .1),
|
|
152
|
+
H: a
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}, fe = (e, t) => {
|
|
156
|
+
let i = d(e);
|
|
157
|
+
return Array.from({ length: t }, (e, a) => {
|
|
158
|
+
let o = 1 / (a + 1), s = 1 / t, c = (o - s) / (1 - s);
|
|
159
|
+
return f({
|
|
160
|
+
L: r(.28, .88, c),
|
|
161
|
+
C: n(r(i.C * 1.3, i.C * .5, c)),
|
|
162
|
+
H: i.H
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
}, pe = (e, t) => {
|
|
166
|
+
let r = d(e);
|
|
167
|
+
return Array.from({ length: t }, (e, a) => {
|
|
168
|
+
let o = a / Math.max(t - 1, 1), s = .55 + .25 * Math.sin(i * o * 1 + 0), c = r.C * (.7 + .5 * Math.sin(i * o * 1.5 + Math.PI / 3)), l = (r.H + 60 * Math.sin(i * o * .75 + Math.PI / 6) + 360) % 360;
|
|
169
|
+
return f({
|
|
170
|
+
L: n(s),
|
|
171
|
+
C: n(c),
|
|
172
|
+
H: l
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
}, me = (e, t) => {
|
|
176
|
+
let n = d(e).H / 120 % 3;
|
|
177
|
+
return Array.from({ length: t }, (e, r) => u(re(r / (t - 1), n, -1.5, 1.2, 1)));
|
|
178
|
+
}, he = (e, t = 5) => {
|
|
179
|
+
let n = e.square ?? [], r = n[0] ?? "#0065ff", i = n[1] ?? "#ff0000", a = n[2] ?? "#00ff00", o = n[3] ?? "#ffff00";
|
|
180
|
+
return {
|
|
181
|
+
random: ie(r, t),
|
|
182
|
+
goldenRatio: ae(r, t),
|
|
183
|
+
noise: oe(r, t),
|
|
184
|
+
temperature: se(r, t),
|
|
185
|
+
bezierInterpolation: ce([
|
|
186
|
+
r,
|
|
187
|
+
i,
|
|
188
|
+
a,
|
|
189
|
+
o
|
|
190
|
+
], t),
|
|
191
|
+
easeInOut: le(r, t),
|
|
192
|
+
blackbody: ue(r, t),
|
|
193
|
+
fibonacci: de(r, t),
|
|
194
|
+
harmonicSeries: fe(r, t),
|
|
195
|
+
sinusoidal: pe(r, t),
|
|
196
|
+
cubehelix: me(r, t)
|
|
197
|
+
};
|
|
198
|
+
}, ge = (e) => ({
|
|
199
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
200
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
201
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
202
|
+
}), y = ({ r: e, g: t, b: n }) => {
|
|
203
|
+
let r = (e) => Math.max(0, Math.min(255, Math.round(e * 255))).toString(16).padStart(2, "0");
|
|
204
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
205
|
+
}, b = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, x = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, S = (e, t, n) => e + (t - e) * n, C = (e, t = 0, n = 1) => Math.max(t, Math.min(n, e)), w = {
|
|
206
|
+
r: 1,
|
|
207
|
+
g: 1,
|
|
208
|
+
b: 1
|
|
209
|
+
}, T = {
|
|
210
|
+
r: 0,
|
|
211
|
+
g: 0,
|
|
212
|
+
b: 0
|
|
213
|
+
}, _e = ({ r: e, g: t, b: n }) => .2126 * b(e) + .7152 * b(t) + .0722 * b(n), E = (e, t) => {
|
|
214
|
+
let n = _e(e), r = _e(t);
|
|
215
|
+
return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
|
|
216
|
+
}, ve = (e, t) => {
|
|
217
|
+
let n = ({ r: e, g: t, b: n }) => .2126729 * e ** 2.4 + .7151522 * t ** 2.4 + .072175 * n ** 2.4, r = .022, i = 1.414, a = 1.14, o = n(e), s = n(t);
|
|
218
|
+
if (o = o > r ? o : o + (r - o) ** i, s = s > r ? s : s + (r - s) ** i, Math.abs(s - o) < 5e-4) return 0;
|
|
219
|
+
if (s > o) {
|
|
220
|
+
let e = (s ** .56 - o ** .57) * a;
|
|
221
|
+
return e < .1 ? 0 : (e - .027) * 100;
|
|
222
|
+
}
|
|
223
|
+
{
|
|
224
|
+
let e = (s ** .65 - o ** .62) * a;
|
|
225
|
+
return e > -.1 ? 0 : (e + .027) * 100;
|
|
226
|
+
}
|
|
227
|
+
}, ye = ({ r: e, g: t, b: n }) => {
|
|
228
|
+
let r = Math.max(e, t, n), i = Math.min(e, t, n), a = (r + i) / 2;
|
|
229
|
+
if (r === i) return {
|
|
230
|
+
h: 0,
|
|
231
|
+
s: 0,
|
|
232
|
+
l: a
|
|
233
|
+
};
|
|
234
|
+
let o = r - i, s = o / (a > .5 ? 2 - r - i : r + i), c = 0;
|
|
235
|
+
return c = r === e ? (t - n) / o + (t < n ? 6 : 0) : r === t ? (n - e) / o + 2 : (e - t) / o + 4, {
|
|
236
|
+
h: c * 60,
|
|
237
|
+
s,
|
|
238
|
+
l: a
|
|
239
|
+
};
|
|
240
|
+
}, D = ({ h: e, s: t, l: n }) => {
|
|
241
|
+
let r = (1 - Math.abs(2 * n - 1)) * t, i = r * (1 - Math.abs(e / 60 % 2 - 1)), a = n - r / 2, o = 0, s = 0, c = 0;
|
|
242
|
+
return e < 60 ? (o = r, s = i) : e < 120 ? (o = i, s = r) : e < 180 ? (s = r, c = i) : e < 240 ? (s = i, c = r) : e < 300 ? (o = i, c = r) : (o = r, c = i), {
|
|
243
|
+
r: o + a,
|
|
244
|
+
g: s + a,
|
|
245
|
+
b: c + a
|
|
246
|
+
};
|
|
247
|
+
}, be = (e, t, n, r = 48) => {
|
|
248
|
+
if (E(e, t) >= n) return e;
|
|
249
|
+
let i = ye(e), a = null;
|
|
250
|
+
{
|
|
251
|
+
let e = 0, o = i.l;
|
|
252
|
+
for (let s = 0; s < r; s++) {
|
|
253
|
+
let r = (e + o) / 2, s = D({
|
|
254
|
+
...i,
|
|
255
|
+
l: r
|
|
256
|
+
});
|
|
257
|
+
E(s, t) >= n ? (a = s, o = r) : e = r;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (a && E(a, t) >= n) return a;
|
|
261
|
+
{
|
|
262
|
+
let e = i.l, o = 1;
|
|
263
|
+
for (let s = 0; s < r; s++) {
|
|
264
|
+
let r = (e + o) / 2, s = D({
|
|
265
|
+
...i,
|
|
266
|
+
l: r
|
|
267
|
+
});
|
|
268
|
+
E(s, t) >= n ? (a = s, e = r) : o = r;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return a && E(a, t) >= n ? a : E(T, t) >= E(w, t) ? T : w;
|
|
272
|
+
}, xe = (e, t, n, r, i, a, o = 48) => {
|
|
273
|
+
let s = a === "dark" ? 0 : n, c = a === "dark" ? n : 1, l = null;
|
|
274
|
+
for (let n = 0; n < o; n++) {
|
|
275
|
+
let n = (s + c) / 2, o = D({
|
|
276
|
+
h: e,
|
|
277
|
+
s: t,
|
|
278
|
+
l: n
|
|
279
|
+
});
|
|
280
|
+
E(o, r) >= i ? (l = o, a === "dark" ? s = n : c = n) : a === "dark" ? c = n : s = n;
|
|
281
|
+
}
|
|
282
|
+
return l && E(l, r) >= i ? l : E(T, r) >= E(w, r) ? T : w;
|
|
283
|
+
}, Se = ({ r: e, g: t, b: n }) => {
|
|
284
|
+
let r = b(e), i = b(t), a = b(n);
|
|
285
|
+
return {
|
|
286
|
+
r: x(C(.29031 * r + .70969 * i + 0 * a)),
|
|
287
|
+
g: x(C(.29031 * r + .70969 * i + 0 * a)),
|
|
288
|
+
b: x(C(-.02197 * r + .02197 * i + 1 * a))
|
|
289
|
+
};
|
|
290
|
+
}, Ce = ({ r: e, g: t, b: n }) => {
|
|
291
|
+
let r = b(e), i = b(t), a = b(n);
|
|
292
|
+
return {
|
|
293
|
+
r: x(C(.10889 * r + .89111 * i + 0 * a)),
|
|
294
|
+
g: x(C(.10889 * r + .89111 * i + 0 * a)),
|
|
295
|
+
b: x(C(.00452 * r - .00452 * i + 1 * a))
|
|
296
|
+
};
|
|
297
|
+
}, we = (e, t) => Math.sqrt((e.r - t.r) ** 2 + (e.g - t.g) ** 2 + (e.b - t.b) ** 2), Te = (e, t, n = .12) => we(Se(e), Se(t)) > n || we(Ce(e), Ce(t)) > n, Ee = (e, t = 9) => {
|
|
298
|
+
let n = Object.values(e).find((e) => Array.isArray(e) && e.length > 0);
|
|
299
|
+
if (!n) return {};
|
|
300
|
+
let r = ye(ge(n[0])), i = {};
|
|
301
|
+
i.contrastScale = Array.from({ length: t }, (e, n) => {
|
|
302
|
+
let i = n / (t - 1);
|
|
303
|
+
return y(D({
|
|
304
|
+
h: r.h,
|
|
305
|
+
s: r.s,
|
|
306
|
+
l: i ** .8
|
|
307
|
+
}));
|
|
308
|
+
});
|
|
309
|
+
{
|
|
310
|
+
let e = Math.ceil(t / 2);
|
|
311
|
+
i.accessible = Array.from({ length: t }, (t, n) => {
|
|
312
|
+
let i = n % 2 == 0, a = i ? S(.05, .35, n / 2 / e) : S(.88, .98, Math.floor(n / 2) / e);
|
|
313
|
+
return y(be(D({
|
|
314
|
+
h: r.h,
|
|
315
|
+
s: r.s * .6,
|
|
316
|
+
l: a
|
|
317
|
+
}), D(i ? {
|
|
318
|
+
h: r.h,
|
|
319
|
+
s: r.s * .1,
|
|
320
|
+
l: .96
|
|
321
|
+
} : {
|
|
322
|
+
h: r.h,
|
|
323
|
+
s: r.s * .8,
|
|
324
|
+
l: .15
|
|
325
|
+
}), 4.5));
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
{
|
|
329
|
+
let e = [
|
|
330
|
+
{
|
|
331
|
+
bg: w,
|
|
332
|
+
ratio: 4.5,
|
|
333
|
+
startL: .2
|
|
334
|
+
},
|
|
335
|
+
{
|
|
336
|
+
bg: w,
|
|
337
|
+
ratio: 7,
|
|
338
|
+
startL: .1
|
|
339
|
+
},
|
|
340
|
+
{
|
|
341
|
+
bg: T,
|
|
342
|
+
ratio: 4.5,
|
|
343
|
+
startL: .8
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
bg: T,
|
|
347
|
+
ratio: 7,
|
|
348
|
+
startL: .9
|
|
349
|
+
}
|
|
350
|
+
];
|
|
351
|
+
i.wcag = Array.from({ length: t }, (t, n) => {
|
|
352
|
+
let { bg: i, ratio: a, startL: o } = e[n % e.length], s = Math.floor(n / e.length), c = C(1 - s * .3), l = s * (o < .5 ? .08 : -.08);
|
|
353
|
+
return y(be(D({
|
|
354
|
+
h: r.h,
|
|
355
|
+
s: r.s * c,
|
|
356
|
+
l: C(o + l)
|
|
357
|
+
}), i, a));
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
{
|
|
361
|
+
let e = {
|
|
362
|
+
r: 1,
|
|
363
|
+
g: 1,
|
|
364
|
+
b: 1
|
|
365
|
+
};
|
|
366
|
+
i.apca = Array.from({ length: t }, (n, i) => {
|
|
367
|
+
let a = S(30, 90, i / (t - 1)), o = 0, s = 1;
|
|
368
|
+
for (let t = 0; t < 48; t++) {
|
|
369
|
+
let t = (o + s) / 2, n = D({
|
|
370
|
+
h: r.h,
|
|
371
|
+
s: r.s,
|
|
372
|
+
l: t
|
|
373
|
+
});
|
|
374
|
+
Math.abs(ve(n, e)) > a ? o = t : s = t;
|
|
375
|
+
}
|
|
376
|
+
return y(D({
|
|
377
|
+
h: r.h,
|
|
378
|
+
s: r.s,
|
|
379
|
+
l: (o + s) / 2
|
|
380
|
+
}));
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
{
|
|
384
|
+
let e = [
|
|
385
|
+
202,
|
|
386
|
+
27,
|
|
387
|
+
56,
|
|
388
|
+
180,
|
|
389
|
+
291,
|
|
390
|
+
343,
|
|
391
|
+
120,
|
|
392
|
+
240,
|
|
393
|
+
30
|
|
394
|
+
], n = [];
|
|
395
|
+
for (let i = 0; i < t; i++) {
|
|
396
|
+
let a = e[i % e.length], o = S(r.h, a, .65), s = S(.25, .75, i / Math.max(t - 1, 1)), c = D({
|
|
397
|
+
h: o,
|
|
398
|
+
s: C(r.s, .4, .85),
|
|
399
|
+
l: s
|
|
400
|
+
});
|
|
401
|
+
i > 0 && !Te(c, ge(n[i - 1])) && (c = D({
|
|
402
|
+
h: o,
|
|
403
|
+
s: r.s,
|
|
404
|
+
l: C(s + .15)
|
|
405
|
+
})), n.push(y(c));
|
|
406
|
+
}
|
|
407
|
+
i.colorBlindSafe = n;
|
|
408
|
+
}
|
|
409
|
+
{
|
|
410
|
+
let e = [
|
|
411
|
+
{
|
|
412
|
+
name: "background",
|
|
413
|
+
l: .97,
|
|
414
|
+
s: .08
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
name: "surface",
|
|
418
|
+
l: .93,
|
|
419
|
+
s: .12
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
name: "border",
|
|
423
|
+
l: .8,
|
|
424
|
+
s: .18
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
name: "muted",
|
|
428
|
+
l: .65,
|
|
429
|
+
s: .25
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "default",
|
|
433
|
+
l: .45,
|
|
434
|
+
s: r.s
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
name: "emphasis",
|
|
438
|
+
l: .35,
|
|
439
|
+
s: r.s
|
|
440
|
+
},
|
|
441
|
+
{
|
|
442
|
+
name: "strong",
|
|
443
|
+
l: .22,
|
|
444
|
+
s: r.s
|
|
445
|
+
},
|
|
446
|
+
{
|
|
447
|
+
name: "onColor",
|
|
448
|
+
l: .98,
|
|
449
|
+
s: .05
|
|
450
|
+
},
|
|
451
|
+
{
|
|
452
|
+
name: "error",
|
|
453
|
+
l: .4,
|
|
454
|
+
s: .85,
|
|
455
|
+
h: 0
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
name: "success",
|
|
459
|
+
l: .35,
|
|
460
|
+
s: .6,
|
|
461
|
+
h: 142
|
|
462
|
+
}
|
|
463
|
+
];
|
|
464
|
+
i.colorTokenized = Array.from({ length: t }, (t, n) => {
|
|
465
|
+
let { h: i, s: a, l: o } = e[n % e.length];
|
|
466
|
+
return y(D({
|
|
467
|
+
h: i ?? r.h,
|
|
468
|
+
s: a,
|
|
469
|
+
l: o
|
|
470
|
+
}));
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
{
|
|
474
|
+
let e = Math.ceil(t / 2), n = t - e;
|
|
475
|
+
i.highContrast = Array.from({ length: t }, (t, i) => {
|
|
476
|
+
if (i < e) {
|
|
477
|
+
let t = i / Math.max(e - 1, 1), n = S(.05, .28, t), a = C(S(r.s, 0, t), 0, 1);
|
|
478
|
+
return y(xe(r.h, a, n, w, 7, "dark"));
|
|
479
|
+
}
|
|
480
|
+
{
|
|
481
|
+
let t = S(.65, .98, (i - e) / Math.max(n - 1, 1)), a = C(r.s * .7, .2, .8);
|
|
482
|
+
return y(xe(r.h, a, t, T, 7, "light"));
|
|
483
|
+
}
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
return i;
|
|
487
|
+
}, De = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, Oe = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, O = (e) => Math.max(0, Math.min(1, e)), k = (e, t, n) => e + (t - e) * n, ke = ({ r: e, g: t, b: n }) => {
|
|
488
|
+
let r = De(e), i = De(t), a = De(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
|
|
489
|
+
return {
|
|
490
|
+
L: .2104542553 * o + .793617785 * s - .0040720468 * c,
|
|
491
|
+
a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
|
|
492
|
+
b: .0259040371 * o + .7827717662 * s - .808675766 * c
|
|
493
|
+
};
|
|
494
|
+
}, Ae = ({ L: e, a: t, b: n }) => {
|
|
495
|
+
let r = e + .3963377774 * t + .2158037573 * n, i = e - .1055613458 * t - .0638541728 * n, a = e - .0894841775 * t - 1.291485548 * n, o = r * r * r, s = i * i * i, c = a * a * a;
|
|
496
|
+
return {
|
|
497
|
+
r: O(Oe(4.0767416621 * o - 3.3077115913 * s + .2309699292 * c)),
|
|
498
|
+
g: O(Oe(-1.2684380046 * o + 2.6097574011 * s - .3413193965 * c)),
|
|
499
|
+
b: O(Oe(-.0041960863 * o - .7034186147 * s + 1.707614701 * c))
|
|
500
|
+
};
|
|
501
|
+
}, je = ({ L: e, a: t, b: n }) => ({
|
|
502
|
+
L: e,
|
|
503
|
+
C: Math.sqrt(t * t + n * n),
|
|
504
|
+
H: (Math.atan2(n, t) * 180 / Math.PI + 360) % 360
|
|
505
|
+
}), Me = ({ L: e, C: t, H: n }) => ({
|
|
506
|
+
L: e,
|
|
507
|
+
a: t * Math.cos(n * Math.PI / 180),
|
|
508
|
+
b: t * Math.sin(n * Math.PI / 180)
|
|
509
|
+
}), Ne = (e) => ({
|
|
510
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
511
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
512
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
513
|
+
}), Pe = ({ r: e, g: t, b: n }) => {
|
|
514
|
+
let r = (e) => Math.round(e * 255).toString(16).padStart(2, "0");
|
|
515
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
516
|
+
}, A = (e) => je(ke(Ne(e))), j = (e) => Pe(Ae(Me(e))), Fe = (e, t, n) => {
|
|
517
|
+
let r = t - e;
|
|
518
|
+
return r > 180 && (r -= 360), r < -180 && (r += 360), (e + r * n + 360) % 360;
|
|
519
|
+
}, Ie = (e, t, n) => ({
|
|
520
|
+
L: k(e.L, t.L, n),
|
|
521
|
+
C: k(e.C, t.C, n),
|
|
522
|
+
H: Fe(e.H, t.H, n)
|
|
523
|
+
}), Le = (e, t) => {
|
|
524
|
+
let n = A(e);
|
|
525
|
+
return Array.from({ length: t }, (e, r) => j({
|
|
526
|
+
L: k(.92, .25, r / (t - 1)),
|
|
527
|
+
C: n.C,
|
|
528
|
+
H: n.H
|
|
529
|
+
}));
|
|
530
|
+
}, Re = (e, t, n) => {
|
|
531
|
+
let r = A(e), i = A(t), a = {
|
|
532
|
+
L: .9,
|
|
533
|
+
C: .02,
|
|
534
|
+
H: r.H
|
|
535
|
+
};
|
|
536
|
+
return Array.from({ length: n }, (e, t) => {
|
|
537
|
+
let o = t / (n - 1), s = o * 2;
|
|
538
|
+
if (o <= .5) return j(Ie({
|
|
539
|
+
...r,
|
|
540
|
+
L: .4
|
|
541
|
+
}, a, s));
|
|
542
|
+
{
|
|
543
|
+
let e = {
|
|
544
|
+
...i,
|
|
545
|
+
L: .4
|
|
546
|
+
};
|
|
547
|
+
return j(Ie(a, e, s - 1));
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
}, ze = (e, t) => {
|
|
551
|
+
let n = A(e), r = O(k(.55, .65, .5)), i = Math.max(n.C, .12);
|
|
552
|
+
return Array.from({ length: t }, (e, a) => {
|
|
553
|
+
let o = (n.H + 360 / t * a) % 360;
|
|
554
|
+
return j({
|
|
555
|
+
L: r,
|
|
556
|
+
C: i,
|
|
557
|
+
H: o
|
|
558
|
+
});
|
|
559
|
+
});
|
|
560
|
+
}, Be = (e, t, n) => {
|
|
561
|
+
let r = A(e), i = A(t), a = [
|
|
562
|
+
{
|
|
563
|
+
L: .85,
|
|
564
|
+
C: r.C * .5,
|
|
565
|
+
H: r.H
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
L: .45,
|
|
569
|
+
C: r.C,
|
|
570
|
+
H: r.H
|
|
571
|
+
},
|
|
572
|
+
{
|
|
573
|
+
L: .85,
|
|
574
|
+
C: i.C * .5,
|
|
575
|
+
H: i.H
|
|
576
|
+
},
|
|
577
|
+
{
|
|
578
|
+
L: .45,
|
|
579
|
+
C: Math.max(r.C, i.C),
|
|
580
|
+
H: Fe(r.H, i.H, .5)
|
|
581
|
+
}
|
|
582
|
+
];
|
|
583
|
+
return Array.from({ length: n }, (e, t) => {
|
|
584
|
+
let r = t / Math.max(n - 1, 1) * (a.length - 1), i = Math.floor(r), o = Math.min(i + 1, a.length - 1);
|
|
585
|
+
return j(Ie(a[i], a[o], r - i));
|
|
586
|
+
});
|
|
587
|
+
}, Ve = (e, t) => {
|
|
588
|
+
let n = A(e), r = O(n.L > .7 ? n.L : .62), i = Math.max(n.C, .12);
|
|
589
|
+
return Array.from({ length: t }, (e, a) => {
|
|
590
|
+
let o = a / t, s = (n.H + 360 * o) % 360;
|
|
591
|
+
return j({
|
|
592
|
+
L: r,
|
|
593
|
+
C: i,
|
|
594
|
+
H: s
|
|
595
|
+
});
|
|
596
|
+
});
|
|
597
|
+
}, He = (e, t) => {
|
|
598
|
+
let n = A(e), r = (n.H - 30 + 360) % 360, i = [
|
|
599
|
+
0,
|
|
600
|
+
30,
|
|
601
|
+
60,
|
|
602
|
+
120,
|
|
603
|
+
180,
|
|
604
|
+
240,
|
|
605
|
+
280
|
|
606
|
+
].map((e) => (e + r) % 360), a = Math.max(n.C, .14), o = [
|
|
607
|
+
.45,
|
|
608
|
+
.6,
|
|
609
|
+
.8,
|
|
610
|
+
.72,
|
|
611
|
+
.62,
|
|
612
|
+
.5,
|
|
613
|
+
.42
|
|
614
|
+
];
|
|
615
|
+
return Array.from({ length: t }, (e, n) => {
|
|
616
|
+
let r = n / (t - 1) * (i.length - 1), s = Math.floor(r), c = Math.min(s + 1, i.length - 1), l = r - s;
|
|
617
|
+
return j({
|
|
618
|
+
L: k(o[s], o[c], l),
|
|
619
|
+
C: a,
|
|
620
|
+
H: Fe(i[s], i[c], l)
|
|
621
|
+
});
|
|
622
|
+
});
|
|
623
|
+
}, Ue = (e, t) => {
|
|
624
|
+
let n = A(e), r = .5800000000000001 / t;
|
|
625
|
+
return Array.from({ length: t }, (e, t) => j({
|
|
626
|
+
L: .88 - r * (t + .5),
|
|
627
|
+
C: n.C * .85,
|
|
628
|
+
H: n.H
|
|
629
|
+
}));
|
|
630
|
+
}, We = (e, t = 4) => {
|
|
631
|
+
let n = e.square ?? [], r = n[0] ?? "#0000ff", i = n[1] ?? "#ff0000", a = n[2] ?? "#00ff00";
|
|
632
|
+
return {
|
|
633
|
+
sequential: Le(r, t),
|
|
634
|
+
diverging: Re(r, a, t),
|
|
635
|
+
qualitative: ze(r, t),
|
|
636
|
+
bivariate: Be(r, i, t),
|
|
637
|
+
cyclical: Ve(r, t),
|
|
638
|
+
spectral: He(r, t),
|
|
639
|
+
stepped: Ue(r, t)
|
|
640
|
+
};
|
|
641
|
+
}, Ge = (e) => {
|
|
642
|
+
let t = parseInt(e.slice(1, 3), 16) / 255, n = parseInt(e.slice(3, 5), 16) / 255, r = parseInt(e.slice(5, 7), 16) / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = 0, s = 0, c = (i + a) / 2;
|
|
643
|
+
if (i !== a) {
|
|
644
|
+
let e = i - a;
|
|
645
|
+
switch (s = c > .5 ? e / (2 - i - a) : e / (i + a), i) {
|
|
646
|
+
case t:
|
|
647
|
+
o = (n - r) / e + (n < r ? 6 : 0);
|
|
648
|
+
break;
|
|
649
|
+
case n:
|
|
650
|
+
o = (r - t) / e + 2;
|
|
651
|
+
break;
|
|
652
|
+
case r: o = (t - n) / e + 4;
|
|
653
|
+
}
|
|
654
|
+
o /= 6;
|
|
655
|
+
}
|
|
656
|
+
return {
|
|
657
|
+
h: o * 360,
|
|
658
|
+
s: s * 100,
|
|
659
|
+
l: c * 100
|
|
660
|
+
};
|
|
661
|
+
}, Ke = ({ h: e, s: t, l: n }) => {
|
|
662
|
+
let r = n / 100, i = t / 100 * Math.min(r, 1 - r), a = (t) => {
|
|
663
|
+
let n = (t + e / 30) % 12, a = r - i * Math.max(Math.min(n - 3, 9 - n, 1), -1);
|
|
664
|
+
return Math.round(255 * a).toString(16).padStart(2, "0");
|
|
665
|
+
};
|
|
666
|
+
return `#${a(0)}${a(8)}${a(4)}`;
|
|
667
|
+
}, M = (e, t) => ({
|
|
668
|
+
...e,
|
|
669
|
+
h: (e.h + t + 360) % 360
|
|
670
|
+
}), qe = (e, t = 9) => {
|
|
671
|
+
let n = Object.values(e).find((e) => Array.isArray(e) && e.length > 0);
|
|
672
|
+
if (!n || n.length === 0) return {};
|
|
673
|
+
let r = n[0], i = Ge(r), a = {
|
|
674
|
+
analogous: (e) => [
|
|
675
|
+
M(e, -30),
|
|
676
|
+
e,
|
|
677
|
+
M(e, 30)
|
|
678
|
+
],
|
|
679
|
+
complementary: (e) => [e, M(e, 180)],
|
|
680
|
+
splitComplementary: (e) => [
|
|
681
|
+
e,
|
|
682
|
+
M(e, 150),
|
|
683
|
+
M(e, 210)
|
|
684
|
+
],
|
|
685
|
+
triadic: (e) => [
|
|
686
|
+
e,
|
|
687
|
+
M(e, 120),
|
|
688
|
+
M(e, 240)
|
|
689
|
+
],
|
|
690
|
+
tetradic: (e) => [
|
|
691
|
+
e,
|
|
692
|
+
M(e, 60),
|
|
693
|
+
M(e, 180),
|
|
694
|
+
M(e, 240)
|
|
695
|
+
],
|
|
696
|
+
square: (e) => [
|
|
697
|
+
e,
|
|
698
|
+
M(e, 90),
|
|
699
|
+
M(e, 180),
|
|
700
|
+
M(e, 270)
|
|
701
|
+
],
|
|
702
|
+
accentedAnalogous: (e) => [
|
|
703
|
+
M(e, -30),
|
|
704
|
+
e,
|
|
705
|
+
M(e, 30),
|
|
706
|
+
M(e, 180)
|
|
707
|
+
],
|
|
708
|
+
doubleSplitComplementary: (e) => [
|
|
709
|
+
e,
|
|
710
|
+
M(e, 30),
|
|
711
|
+
M(e, 150),
|
|
712
|
+
M(e, 210),
|
|
713
|
+
M(e, 180),
|
|
714
|
+
M(e, 240)
|
|
715
|
+
],
|
|
716
|
+
ambiguous: (e) => [
|
|
717
|
+
M(e, 15),
|
|
718
|
+
M(e, 85),
|
|
719
|
+
M(e, 145)
|
|
720
|
+
]
|
|
721
|
+
}, o = {
|
|
722
|
+
monochromatic: (e, t) => Array.from({ length: t }, (n, r) => ({
|
|
723
|
+
...e,
|
|
724
|
+
l: Math.max(5, Math.min(95, 15 + 70 / (t - 1 || 1) * r))
|
|
725
|
+
})),
|
|
726
|
+
monochromaticTintShade: (e, t) => Array.from({ length: t }, (n, r) => ({
|
|
727
|
+
...e,
|
|
728
|
+
s: Math.max(0, e.s - r * 2),
|
|
729
|
+
l: Math.max(5, Math.min(95, 10 + 80 / (t - 1 || 1) * r))
|
|
730
|
+
}))
|
|
731
|
+
}, s = { harmonyPalette: n };
|
|
732
|
+
return Object.entries(a).forEach(([e, t]) => {
|
|
733
|
+
s[e] = t(i).map(Ke);
|
|
734
|
+
}), Object.entries(o).forEach(([e, n]) => {
|
|
735
|
+
s[e] = n(i, t).map(Ke);
|
|
736
|
+
}), s;
|
|
737
|
+
}, Je = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, Ye = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, N = (e) => Math.max(0, Math.min(1, e)), Xe = ({ r: e, g: t, b: n }) => {
|
|
738
|
+
let r = Je(e), i = Je(t), a = Je(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
|
|
739
|
+
return {
|
|
740
|
+
L: .2104542553 * o + .793617785 * s - .0040720468 * c,
|
|
741
|
+
a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
|
|
742
|
+
b: .0259040371 * o + .7827717662 * s - .808675766 * c
|
|
743
|
+
};
|
|
744
|
+
}, Ze = ({ L: e, a: t, b: n }) => {
|
|
745
|
+
let r = e + .3963377774 * t + .2158037573 * n, i = e - .1055613458 * t - .0638541728 * n, a = e - .0894841775 * t - 1.291485548 * n, o = r * r * r, s = i * i * i, c = a * a * a;
|
|
746
|
+
return {
|
|
747
|
+
r: N(Ye(4.0767416621 * o - 3.3077115913 * s + .2309699292 * c)),
|
|
748
|
+
g: N(Ye(-1.2684380046 * o + 2.6097574011 * s - .3413193965 * c)),
|
|
749
|
+
b: N(Ye(-.0041960863 * o - .7034186147 * s + 1.707614701 * c))
|
|
750
|
+
};
|
|
751
|
+
}, P = (e, t) => (e.L - t.L) ** 2 + (e.a - t.a) ** 2 + (e.b - t.b) ** 2, F = (e) => Math.sqrt(e.a * e.a + e.b * e.b), Qe = (e) => ({
|
|
752
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
753
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
754
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
755
|
+
}), I = ({ r: e, g: t, b: n }) => {
|
|
756
|
+
let r = (e) => Math.round(e * 255).toString(16).padStart(2, "0");
|
|
757
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
758
|
+
}, L = (e) => I(Ze(e)), R = (e, t) => {
|
|
759
|
+
if (e.length >= t) return e.slice(0, t);
|
|
760
|
+
let n = [...e], r = e[e.length - 1] ?? {
|
|
761
|
+
L: .5,
|
|
762
|
+
a: 0,
|
|
763
|
+
b: 0
|
|
764
|
+
};
|
|
765
|
+
for (; n.length < t;) {
|
|
766
|
+
let e = n.length / t;
|
|
767
|
+
n.push({
|
|
768
|
+
...r,
|
|
769
|
+
L: N(.2 + e * .6)
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
return n;
|
|
773
|
+
}, z = (e, t) => {
|
|
774
|
+
if (e.length >= t) return e.slice(0, t);
|
|
775
|
+
let n = [...e];
|
|
776
|
+
for (; n.length < t;) {
|
|
777
|
+
let e = n.length / t;
|
|
778
|
+
n.push({
|
|
779
|
+
r: e,
|
|
780
|
+
g: e,
|
|
781
|
+
b: e
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
return n;
|
|
785
|
+
}, $e = (e, t = 6e3) => {
|
|
786
|
+
let n = Math.max(1, Math.floor(e.length / 4 / t)), r = [], i = [];
|
|
787
|
+
for (let t = 0; t < e.length; t += 4 * n) {
|
|
788
|
+
if (e[t + 3] < 128) continue;
|
|
789
|
+
let n = {
|
|
790
|
+
r: e[t] / 255,
|
|
791
|
+
g: e[t + 1] / 255,
|
|
792
|
+
b: e[t + 2] / 255
|
|
793
|
+
};
|
|
794
|
+
r.push(n), i.push(Xe(n));
|
|
795
|
+
}
|
|
796
|
+
return {
|
|
797
|
+
rgbs: r,
|
|
798
|
+
labs: i
|
|
799
|
+
};
|
|
800
|
+
}, et = (e) => {
|
|
801
|
+
let t = new Uint8ClampedArray(e.length * 800 * 4), n = 0;
|
|
802
|
+
for (let r of e) {
|
|
803
|
+
let e = Qe(r);
|
|
804
|
+
for (let r = 0; r < 800; r++) {
|
|
805
|
+
let r = () => (Math.random() - .5) * 30;
|
|
806
|
+
t[n++] = Math.round(N(e.r) * 255 + r()), t[n++] = Math.round(N(e.g) * 255 + r()), t[n++] = Math.round(N(e.b) * 255 + r()), t[n++] = 255;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return t;
|
|
810
|
+
}, B = (e, t, n = 25) => {
|
|
811
|
+
if (e.length === 0) return [];
|
|
812
|
+
let r = e.filter((e) => {
|
|
813
|
+
let t = F(e);
|
|
814
|
+
return Math.random() <= (t < .05 ? .2 : t < .15 ? .6 : 1);
|
|
815
|
+
}), i = r.length >= t ? r : e, a = i.length, o = [i[Math.floor(Math.random() * a)]];
|
|
816
|
+
for (let e = 1; e < t; e++) {
|
|
817
|
+
let e = i.map((e) => Math.min(...o.map((t) => P(e, t)))), t = e.reduce((e, t) => e + t, 0), n = Math.random() * t, r = 0;
|
|
818
|
+
for (let t = 0; t < a; t++) if (n -= e[t], n <= 0) {
|
|
819
|
+
r = t;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
o.push({ ...i[r] });
|
|
823
|
+
}
|
|
824
|
+
let s = new Int32Array(a);
|
|
825
|
+
for (let e = 0; e < n; e++) {
|
|
826
|
+
let e = !1;
|
|
827
|
+
for (let n = 0; n < a; n++) {
|
|
828
|
+
let r = 0, a = Infinity;
|
|
829
|
+
for (let e = 0; e < t; e++) {
|
|
830
|
+
let t = P(i[n], o[e]);
|
|
831
|
+
t < a && (a = t, r = e);
|
|
832
|
+
}
|
|
833
|
+
s[n] !== r && (s[n] = r, e = !0);
|
|
834
|
+
}
|
|
835
|
+
if (!e) break;
|
|
836
|
+
let n = Array.from({ length: t }, () => ({
|
|
837
|
+
L: 0,
|
|
838
|
+
a: 0,
|
|
839
|
+
b: 0,
|
|
840
|
+
count: 0
|
|
841
|
+
}));
|
|
842
|
+
for (let e = 0; e < a; e++) {
|
|
843
|
+
let t = s[e];
|
|
844
|
+
n[t].L += i[e].L, n[t].a += i[e].a, n[t].b += i[e].b, n[t].count++;
|
|
845
|
+
}
|
|
846
|
+
for (let e = 0; e < t; e++) n[e].count > 0 && (o[e] = {
|
|
847
|
+
L: n[e].L / n[e].count,
|
|
848
|
+
a: n[e].a / n[e].count,
|
|
849
|
+
b: n[e].b / n[e].count
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
let c = Array(t).fill(0);
|
|
853
|
+
for (let e = 0; e < a; e++) c[s[e]]++;
|
|
854
|
+
return R(o.map((e, t) => ({
|
|
855
|
+
lab: e,
|
|
856
|
+
score: c[t] * (1 + 3 * F(e))
|
|
857
|
+
})).sort((e, t) => t.score - e.score).map((e) => e.lab), t);
|
|
858
|
+
}, tt = (e, t) => {
|
|
859
|
+
if (e.length === 0) return z([], t);
|
|
860
|
+
let n = [{ pixels: [...e] }], r = (e) => {
|
|
861
|
+
let t = 1, n = 0, r = 1, i = 0, a = 1, o = 0;
|
|
862
|
+
for (let s of e.pixels) t = Math.min(t, s.r), n = Math.max(n, s.r), r = Math.min(r, s.g), i = Math.max(i, s.g), a = Math.min(a, s.b), o = Math.max(o, s.b);
|
|
863
|
+
let s = n - t >= i - r && n - t >= o - a ? "r" : i - r >= o - a ? "g" : "b";
|
|
864
|
+
e.pixels.sort((e, t) => e[s] - t[s]);
|
|
865
|
+
let c = Math.floor(e.pixels.length / 2);
|
|
866
|
+
return [{ pixels: e.pixels.slice(0, c) }, { pixels: e.pixels.slice(c) }];
|
|
867
|
+
};
|
|
868
|
+
for (; n.length < t && (n.sort((e, t) => t.pixels.length - e.pixels.length), !(n[0].pixels.length < 2));) {
|
|
869
|
+
let [e, t] = r(n.shift());
|
|
870
|
+
n.push(e, t);
|
|
871
|
+
}
|
|
872
|
+
return z(n.map((e) => {
|
|
873
|
+
let t = e.pixels.length;
|
|
874
|
+
return {
|
|
875
|
+
r: e.pixels.reduce((e, t) => e + t.r, 0) / t,
|
|
876
|
+
g: e.pixels.reduce((e, t) => e + t.g, 0) / t,
|
|
877
|
+
b: e.pixels.reduce((e, t) => e + t.b, 0) / t
|
|
878
|
+
};
|
|
879
|
+
}), t);
|
|
880
|
+
}, nt = (e, t) => {
|
|
881
|
+
let n = /* @__PURE__ */ new Map();
|
|
882
|
+
for (let t of e) {
|
|
883
|
+
let e = Math.round(t.r * 7) / 7, r = Math.round(t.g * 7) / 7, i = Math.round(t.b * 7) / 7, a = `${e},${r},${i}`, o = n.get(a);
|
|
884
|
+
o ? o.count++ : n.set(a, {
|
|
885
|
+
rgb: {
|
|
886
|
+
r: e,
|
|
887
|
+
g: r,
|
|
888
|
+
b: i
|
|
889
|
+
},
|
|
890
|
+
count: 1
|
|
891
|
+
});
|
|
892
|
+
}
|
|
893
|
+
return z(Array.from(n.values()).sort((e, t) => t.count - e.count).slice(0, t).map((e) => e.rgb), t);
|
|
894
|
+
}, rt = (e, t) => {
|
|
895
|
+
let n = e.filter((e) => F(e) > .1 && e.L > .25 && e.L < .85);
|
|
896
|
+
return B(n.length >= t ? n : e, t);
|
|
897
|
+
}, it = (e, t) => {
|
|
898
|
+
let n = e.filter((e) => {
|
|
899
|
+
let t = F(e);
|
|
900
|
+
return t >= .02 && t <= .09 && e.L > .2 && e.L < .9;
|
|
901
|
+
});
|
|
902
|
+
return B(n.length >= t ? n : e, t);
|
|
903
|
+
}, at = (e, t) => {
|
|
904
|
+
let n = () => ({
|
|
905
|
+
r: 0,
|
|
906
|
+
g: 0,
|
|
907
|
+
b: 0,
|
|
908
|
+
count: 0,
|
|
909
|
+
children: Array(8).fill(null),
|
|
910
|
+
isLeaf: !1
|
|
911
|
+
}), r = n(), i = (e, t, r, a, o) => {
|
|
912
|
+
if (o === 8) {
|
|
913
|
+
e.isLeaf = !0, e.r += t, e.g += r, e.b += a, e.count++;
|
|
914
|
+
return;
|
|
915
|
+
}
|
|
916
|
+
let s = 7 - o, c = (t >> s & 1) << 2 | (r >> s & 1) << 1 | a >> s & 1;
|
|
917
|
+
e.children[c] || (e.children[c] = n()), i(e.children[c], t, r, a, o + 1);
|
|
918
|
+
}, a = (e) => e.isLeaf && e.count > 0 ? [e] : e.children.filter(Boolean).flatMap((e) => a(e));
|
|
919
|
+
for (let t of e) i(r, Math.round(t.r * 255), Math.round(t.g * 255), Math.round(t.b * 255), 0);
|
|
920
|
+
let o = a(r);
|
|
921
|
+
for (; o.length > t;) o.sort((e, t) => e.count - t.count), o[0].count = 0, o = a(r);
|
|
922
|
+
return z(o.filter((e) => e.count > 0).sort((e, t) => t.count - e.count).slice(0, t).map((e) => ({
|
|
923
|
+
r: N(e.r / e.count / 255),
|
|
924
|
+
g: N(e.g / e.count / 255),
|
|
925
|
+
b: N(e.b / e.count / 255)
|
|
926
|
+
})), t);
|
|
927
|
+
}, ot = (e, t) => {
|
|
928
|
+
if (e.length === 0) return R([], t);
|
|
929
|
+
let n = e.length, r = e.reduce((e, t) => e + t.L, 0) / n, i = e.reduce((e, t) => e + t.a, 0) / n, a = e.reduce((e, t) => e + t.b, 0) / n, o = Math.sqrt(e.reduce((e, t) => e + (t.L - r) ** 2, 0) / n), s = Math.sqrt(e.reduce((e, t) => e + (t.a - i) ** 2, 0) / n), c = Math.sqrt(e.reduce((e, t) => e + (t.b - a) ** 2, 0) / n), l = Math.cbrt(e.reduce((e, t) => e + (t.L - r) ** 3, 0) / n), u = Math.cbrt(e.reduce((e, t) => e + (t.a - i) ** 3, 0) / n), d = Math.cbrt(e.reduce((e, t) => e + (t.b - a) ** 3, 0) / n);
|
|
930
|
+
return Array.from({ length: t }, (e, n) => {
|
|
931
|
+
let f = t === 1 ? 0 : n / (t - 1) * 2 - 1;
|
|
932
|
+
return {
|
|
933
|
+
L: N(r + f * o + (f * f - 1 / 3) * l * .3),
|
|
934
|
+
a: N(i + f * s + (f * f - 1 / 3) * u * .3),
|
|
935
|
+
b: N(a + f * c + (f * f - 1 / 3) * d * .3)
|
|
936
|
+
};
|
|
937
|
+
});
|
|
938
|
+
}, st = (e, t) => {
|
|
939
|
+
if (e.length < t) return R(B(e, e.length), t);
|
|
940
|
+
let n = Array.from({ length: t }, (n, r) => ({ ...e[Math.floor(r / t * e.length)] })), r = Math.min(e.length, 4e3), i = Math.max(1, Math.floor(e.length / r));
|
|
941
|
+
for (let a = 0; a < r; a++) {
|
|
942
|
+
let o = e[a * i % e.length], s = .4 * (1 - a / r), c = 0, l = Infinity;
|
|
943
|
+
for (let e = 0; e < t; e++) {
|
|
944
|
+
let t = P(o, n[e]);
|
|
945
|
+
t < l && (l = t, c = e);
|
|
946
|
+
}
|
|
947
|
+
let u = Math.max(1, Math.round(t / 4 * (1 - a / r)));
|
|
948
|
+
for (let e = 0; e < t; e++) {
|
|
949
|
+
let t = Math.abs(e - c);
|
|
950
|
+
if (t > u) continue;
|
|
951
|
+
let r = s * Math.exp(-(t * t) / (2 * u * u));
|
|
952
|
+
n[e].L += r * (o.L - n[e].L), n[e].a += r * (o.a - n[e].a), n[e].b += r * (o.b - n[e].b);
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
let a = [];
|
|
956
|
+
for (let e of n) a.some((t) => P(t, e) < 5e-4) || a.push(e);
|
|
957
|
+
return R(a, t);
|
|
958
|
+
}, ct = (e, t) => {
|
|
959
|
+
let n = Array.from({ length: 72 }, () => ({
|
|
960
|
+
sumL: 0,
|
|
961
|
+
sumC: 0,
|
|
962
|
+
count: 0
|
|
963
|
+
}));
|
|
964
|
+
for (let t of e) {
|
|
965
|
+
let e = (Math.atan2(t.b, t.a) * 180 / Math.PI + 360) % 360, r = Math.floor(e / 5) % 72;
|
|
966
|
+
n[r].sumL += t.L, n[r].sumC += F(t), n[r].count++;
|
|
967
|
+
}
|
|
968
|
+
let r = n.map((e, t) => ({
|
|
969
|
+
count: (n[(t - 1 + 72) % 72].count + n[t].count + n[(t + 1) % 72].count) / 3,
|
|
970
|
+
idx: t
|
|
971
|
+
})), i = [];
|
|
972
|
+
for (let e = 0; e < 72; e++) r[e].count > r[(e - 1 + 72) % 72].count && r[e].count >= r[(e + 1) % 72].count && n[e].count > 0 && i.push(e);
|
|
973
|
+
i.sort((e, t) => r[t].count - r[e].count);
|
|
974
|
+
let a = i.slice(0, t), o = [...r].sort((e, t) => t.count - e.count), s = 0;
|
|
975
|
+
for (; a.length < t && s < 72;) !a.includes(o[s].idx) && n[o[s].idx].count > 0 && a.push(o[s].idx), s++;
|
|
976
|
+
let c = 0;
|
|
977
|
+
for (; a.length < t;) a.push(c), c += Math.floor(72 / t);
|
|
978
|
+
return a.slice(0, t).map((e) => {
|
|
979
|
+
let t = e / 72 * 360 + 5 / 2, r = n[e].count > 0 ? n[e].sumL / n[e].count : .5, i = n[e].count > 0 ? n[e].sumC / n[e].count : .12, a = t * Math.PI / 180;
|
|
980
|
+
return {
|
|
981
|
+
L: r,
|
|
982
|
+
a: i * Math.cos(a),
|
|
983
|
+
b: i * Math.sin(a)
|
|
984
|
+
};
|
|
985
|
+
});
|
|
986
|
+
}, lt = (e, t) => {
|
|
987
|
+
if (e.length === 0) return R([], t);
|
|
988
|
+
let n = Math.max(1, Math.floor(e.length / 2e3)), r = e.filter((e, t) => t % n === 0), i = [r.reduce((e, t) => F(t) > F(e) ? t : e)];
|
|
989
|
+
for (; i.length < t;) {
|
|
990
|
+
let e = r[0], t = -Infinity;
|
|
991
|
+
for (let n of r) {
|
|
992
|
+
let r = i.reduce((e, t) => Math.min(e, P(n, t)), Infinity);
|
|
993
|
+
r > t && (t = r, e = n);
|
|
994
|
+
}
|
|
995
|
+
if (t === 0) break;
|
|
996
|
+
i.push(e);
|
|
997
|
+
}
|
|
998
|
+
return R(i, t);
|
|
999
|
+
}, ut = (e, t = 6, n) => {
|
|
1000
|
+
let { rgbs: r, labs: i } = $e(n ?? et(e.square ?? ["#888888"]));
|
|
1001
|
+
if (i.length === 0) {
|
|
1002
|
+
let e = Array(t).fill("#000000");
|
|
1003
|
+
return {
|
|
1004
|
+
kmeans: e,
|
|
1005
|
+
medianCut: e,
|
|
1006
|
+
dominant: e,
|
|
1007
|
+
vibrant: e,
|
|
1008
|
+
muted: e,
|
|
1009
|
+
octree: e,
|
|
1010
|
+
colorMoments: e,
|
|
1011
|
+
neuralQuant: e,
|
|
1012
|
+
histogram: e,
|
|
1013
|
+
deltaE: e
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
return {
|
|
1017
|
+
kmeans: B(i, t).map(L),
|
|
1018
|
+
medianCut: tt(r, t).map(I),
|
|
1019
|
+
dominant: nt(r, t).map(I),
|
|
1020
|
+
vibrant: rt(i, t).map(L),
|
|
1021
|
+
muted: it(i, t).map(L),
|
|
1022
|
+
octree: at(r, t).map(I),
|
|
1023
|
+
colorMoments: ot(i, t).map(L),
|
|
1024
|
+
neuralQuant: st(i, t).map(L),
|
|
1025
|
+
histogram: ct(i, t).map(L),
|
|
1026
|
+
deltaE: lt(i, t).map(L)
|
|
1027
|
+
};
|
|
1028
|
+
}, dt = (e) => ({
|
|
1029
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
1030
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
1031
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
1032
|
+
}), ft = ({ r: e, g: t, b: n }) => {
|
|
1033
|
+
let r = (e) => Math.max(0, Math.min(255, Math.round(e * 255))).toString(16).padStart(2, "0");
|
|
1034
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
1035
|
+
}, V = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, H = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, U = (e, t, n) => e + (t - e) * n, pt = (e, t, n) => {
|
|
1036
|
+
let r = t - e;
|
|
1037
|
+
return (e + (r > 180 ? r - 360 : r < -180 ? r + 360 : r) * n + 360) % 360;
|
|
1038
|
+
}, W = (e) => {
|
|
1039
|
+
let t = V(e.r), n = V(e.g), r = V(e.b), i = .4122 * t + .5363 * n + .0514 * r, a = .2119 * t + .6807 * n + .1074 * r, o = .0883 * t + .2817 * n + .63 * r, s = Math.cbrt(i), c = Math.cbrt(a), l = Math.cbrt(o);
|
|
1040
|
+
return {
|
|
1041
|
+
L: .2104 * s + .7936 * c - .004 * l,
|
|
1042
|
+
a: 1.9779 * s - 2.4285 * c + .4505 * l,
|
|
1043
|
+
b: .0259 * s + .7827 * c - .8086 * l
|
|
1044
|
+
};
|
|
1045
|
+
}, mt = (e) => {
|
|
1046
|
+
let t = e.L + .3963 * e.a + .2158 * e.b, n = e.L - .1055 * e.a - .0638 * e.b, r = e.L - .0894 * e.a - 1.2914 * e.b, i = t * t * t, a = n * n * n, o = r * r * r, s = 4.0767 * i - 3.3077 * a + .2309 * o, c = -1.2684 * i + 2.6097 * a - .3413 * o, l = -.0041 * i - .7034 * a + 1.7076 * o;
|
|
1047
|
+
return {
|
|
1048
|
+
r: H(s),
|
|
1049
|
+
g: H(c),
|
|
1050
|
+
b: H(l)
|
|
1051
|
+
};
|
|
1052
|
+
}, G = (e) => {
|
|
1053
|
+
let t = V(e.r), n = V(e.g), r = V(e.b), i = (.4124 * t + .3575 * n + .1804 * r) / .9504, a = .2126 * t + .7151 * n + .0721 * r, o = (.0193 * t + .1191 * n + .9503 * r) / 1.0888, s = (e) => e > .008856 ? e ** (1 / 3) : 7.787 * e + 16 / 116;
|
|
1054
|
+
return {
|
|
1055
|
+
L: 116 * s(a) - 16,
|
|
1056
|
+
a: 500 * (s(i) - s(a)),
|
|
1057
|
+
b: 200 * (s(a) - s(o))
|
|
1058
|
+
};
|
|
1059
|
+
}, ht = (e) => {
|
|
1060
|
+
let t = (e.L + 16) / 116, n = e.a / 500 + t, r = t - e.b / 200, i = (e) => e > .20689 ? e * e * e : (e - 16 / 116) / 7.787, a = i(n) * .9504, o = i(t), s = i(r) * 1.0888, c = 3.2404 * a - 1.5371 * o - .4985 * s, l = -.9692 * a + 1.8759 * o + .0415 * s, u = .0556 * a - .204 * o + 1.0572 * s;
|
|
1061
|
+
return {
|
|
1062
|
+
r: H(c),
|
|
1063
|
+
g: H(l),
|
|
1064
|
+
b: H(u)
|
|
1065
|
+
};
|
|
1066
|
+
}, gt = (e) => {
|
|
1067
|
+
let t = Math.max(e.r, e.g, e.b), n = t - Math.min(e.r, e.g, e.b), r = 0;
|
|
1068
|
+
return n !== 0 && (r = t === e.r ? (e.g - e.b) / n + (e.g < e.b ? 6 : 0) : t === e.g ? (e.b - e.r) / n + 2 : (e.r - e.g) / n + 4), {
|
|
1069
|
+
h: r * 60,
|
|
1070
|
+
s: t === 0 ? 0 : n / t,
|
|
1071
|
+
v: t
|
|
1072
|
+
};
|
|
1073
|
+
}, _t = ({ h: e, s: t, v: n }) => {
|
|
1074
|
+
let r = Math.floor(e / 60) % 6, i = e / 60 - r, a = n * (1 - t), o = n * (1 - i * t), s = n * (1 - (1 - i) * t);
|
|
1075
|
+
switch (r) {
|
|
1076
|
+
case 0: return {
|
|
1077
|
+
r: n,
|
|
1078
|
+
g: s,
|
|
1079
|
+
b: a
|
|
1080
|
+
};
|
|
1081
|
+
case 1: return {
|
|
1082
|
+
r: o,
|
|
1083
|
+
g: n,
|
|
1084
|
+
b: a
|
|
1085
|
+
};
|
|
1086
|
+
case 2: return {
|
|
1087
|
+
r: a,
|
|
1088
|
+
g: n,
|
|
1089
|
+
b: s
|
|
1090
|
+
};
|
|
1091
|
+
case 3: return {
|
|
1092
|
+
r: a,
|
|
1093
|
+
g: o,
|
|
1094
|
+
b: n
|
|
1095
|
+
};
|
|
1096
|
+
case 4: return {
|
|
1097
|
+
r: s,
|
|
1098
|
+
g: a,
|
|
1099
|
+
b: n
|
|
1100
|
+
};
|
|
1101
|
+
default: return {
|
|
1102
|
+
r: n,
|
|
1103
|
+
g: a,
|
|
1104
|
+
b: o
|
|
1105
|
+
};
|
|
1106
|
+
}
|
|
1107
|
+
}, vt = (e, t = 9) => {
|
|
1108
|
+
let n = Object.values(e).find((e) => Array.isArray(e));
|
|
1109
|
+
if (!n || n.length < 1) return {};
|
|
1110
|
+
let r = n.length === 1 ? [dt(n[0]), dt("#ffffff")] : n.map(dt), i = {};
|
|
1111
|
+
return [
|
|
1112
|
+
"lab",
|
|
1113
|
+
"lch",
|
|
1114
|
+
"oklab",
|
|
1115
|
+
"oklch",
|
|
1116
|
+
"hct",
|
|
1117
|
+
"cam16",
|
|
1118
|
+
"hsl",
|
|
1119
|
+
"hsv",
|
|
1120
|
+
"jzazbz",
|
|
1121
|
+
"ipt"
|
|
1122
|
+
].forEach((e) => {
|
|
1123
|
+
let n = [];
|
|
1124
|
+
for (let i = 0; i < t; i++) {
|
|
1125
|
+
let a = i / (t - 1) * (r.length - 1), o = Math.min(Math.floor(a), r.length - 2), s = a - o, c = r[o], l = r[o + 1], u;
|
|
1126
|
+
switch (e) {
|
|
1127
|
+
case "oklab": {
|
|
1128
|
+
let e = W(c), t = W(l);
|
|
1129
|
+
u = mt({
|
|
1130
|
+
L: U(e.L, t.L, s),
|
|
1131
|
+
a: U(e.a, t.a, s),
|
|
1132
|
+
b: U(e.b, t.b, s)
|
|
1133
|
+
});
|
|
1134
|
+
break;
|
|
1135
|
+
}
|
|
1136
|
+
case "oklch": {
|
|
1137
|
+
let e = W(c), t = W(l), n = Math.atan2(e.b, e.a) * 180 / Math.PI, r = Math.atan2(t.b, t.a) * 180 / Math.PI, i = Math.sqrt(e.a ** 2 + e.b ** 2), a = Math.sqrt(t.a ** 2 + t.b ** 2), o = pt(n, r, s) * Math.PI / 180, d = U(i, a, s);
|
|
1138
|
+
u = mt({
|
|
1139
|
+
L: U(e.L, t.L, s),
|
|
1140
|
+
a: d * Math.cos(o),
|
|
1141
|
+
b: d * Math.sin(o)
|
|
1142
|
+
});
|
|
1143
|
+
break;
|
|
1144
|
+
}
|
|
1145
|
+
case "lab": {
|
|
1146
|
+
let e = G(c), t = G(l);
|
|
1147
|
+
u = ht({
|
|
1148
|
+
L: U(e.L, t.L, s),
|
|
1149
|
+
a: U(e.a, t.a, s),
|
|
1150
|
+
b: U(e.b, t.b, s)
|
|
1151
|
+
});
|
|
1152
|
+
break;
|
|
1153
|
+
}
|
|
1154
|
+
case "lch": {
|
|
1155
|
+
let e = G(c), t = G(l), n = Math.atan2(e.b, e.a) * 180 / Math.PI, r = Math.atan2(t.b, t.a) * 180 / Math.PI, i = Math.sqrt(e.a ** 2 + e.b ** 2), a = Math.sqrt(t.a ** 2 + t.b ** 2), o = pt(n, r, s) * Math.PI / 180, d = U(i, a, s);
|
|
1156
|
+
u = ht({
|
|
1157
|
+
L: U(e.L, t.L, s),
|
|
1158
|
+
a: d * Math.cos(o),
|
|
1159
|
+
b: d * Math.sin(o)
|
|
1160
|
+
});
|
|
1161
|
+
break;
|
|
1162
|
+
}
|
|
1163
|
+
case "hsl":
|
|
1164
|
+
case "hsv": {
|
|
1165
|
+
let e = gt(c), t = gt(l);
|
|
1166
|
+
u = _t({
|
|
1167
|
+
h: pt(e.h, t.h, s),
|
|
1168
|
+
s: U(e.s, t.s, s),
|
|
1169
|
+
v: U(e.v, t.v, s)
|
|
1170
|
+
});
|
|
1171
|
+
break;
|
|
1172
|
+
}
|
|
1173
|
+
case "ipt":
|
|
1174
|
+
case "jzazbz":
|
|
1175
|
+
case "cam16":
|
|
1176
|
+
case "hct": {
|
|
1177
|
+
u = {
|
|
1178
|
+
r: H(U(V(c.r), V(l.r), s)),
|
|
1179
|
+
g: H(U(V(c.g), V(l.g), s)),
|
|
1180
|
+
b: H(U(V(c.b), V(l.b), s))
|
|
1181
|
+
};
|
|
1182
|
+
let t = Math.sin(Math.PI * s) * (e === "jzazbz" ? .05 : .02);
|
|
1183
|
+
u.r = Math.min(1, u.r + t);
|
|
1184
|
+
break;
|
|
1185
|
+
}
|
|
1186
|
+
default: u = {
|
|
1187
|
+
r: U(c.r, l.r, s),
|
|
1188
|
+
g: U(c.g, l.g, s),
|
|
1189
|
+
b: U(c.b, l.b, s)
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
n.push(ft(u));
|
|
1193
|
+
}
|
|
1194
|
+
i[e] = n;
|
|
1195
|
+
}), i;
|
|
1196
|
+
}, K = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, yt = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, q = (e) => Math.max(0, Math.min(1, e)), bt = (e, t, n) => e + (t - e) * n, xt = (e) => ({
|
|
1197
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
1198
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
1199
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
1200
|
+
}), St = ({ r: e, g: t, b: n }) => {
|
|
1201
|
+
let r = (e) => Math.round(q(e) * 255).toString(16).padStart(2, "0");
|
|
1202
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
1203
|
+
}, Ct = ({ r: e, g: t, b: n }) => {
|
|
1204
|
+
let r = K(e), i = K(t), a = K(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
|
|
1205
|
+
return {
|
|
1206
|
+
L: .2104542553 * o + .793617785 * s - .0040720468 * c,
|
|
1207
|
+
a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
|
|
1208
|
+
b: .0259040371 * o + .7827717662 * s - .808675766 * c
|
|
1209
|
+
};
|
|
1210
|
+
}, wt = ({ L: e, a: t, b: n }) => {
|
|
1211
|
+
let r = e + .3963377774 * t + .2158037573 * n, i = e - .1055613458 * t - .0638541728 * n, a = e - .0894841775 * t - 1.291485548 * n, o = r * r * r, s = i * i * i, c = a * a * a;
|
|
1212
|
+
return {
|
|
1213
|
+
r: yt(4.0767416621 * o - 3.3077115913 * s + .2309699292 * c),
|
|
1214
|
+
g: yt(-1.2684380046 * o + 2.6097574011 * s - .3413193965 * c),
|
|
1215
|
+
b: yt(-.0041960863 * o - .7034186147 * s + 1.707614701 * c)
|
|
1216
|
+
};
|
|
1217
|
+
}, Tt = (e) => {
|
|
1218
|
+
let { r: t, g: n, b: r } = wt(e);
|
|
1219
|
+
return {
|
|
1220
|
+
r: q(t),
|
|
1221
|
+
g: q(n),
|
|
1222
|
+
b: q(r)
|
|
1223
|
+
};
|
|
1224
|
+
}, Et = ({ L: e, a: t, b: n }) => ({
|
|
1225
|
+
L: e,
|
|
1226
|
+
C: Math.sqrt(t * t + n * n),
|
|
1227
|
+
H: (Math.atan2(n, t) * 180 / Math.PI + 360) % 360
|
|
1228
|
+
}), J = ({ L: e, C: t, H: n }) => ({
|
|
1229
|
+
L: e,
|
|
1230
|
+
a: t * Math.cos(n * Math.PI / 180),
|
|
1231
|
+
b: t * Math.sin(n * Math.PI / 180)
|
|
1232
|
+
}), Dt = (e) => Et(Ct(xt(e))), Y = (e) => {
|
|
1233
|
+
let t = (e) => e.r >= -.001 && e.r <= 1.001 && e.g >= -.001 && e.g <= 1.001 && e.b >= -.001 && e.b <= 1.001;
|
|
1234
|
+
if (t(wt(J(e)))) return St(Tt(J(e)));
|
|
1235
|
+
let n = 0, r = e.C;
|
|
1236
|
+
for (let i = 0; i < 24; i++) {
|
|
1237
|
+
let i = (n + r) / 2;
|
|
1238
|
+
t(wt(J({
|
|
1239
|
+
...e,
|
|
1240
|
+
C: i
|
|
1241
|
+
}))) ? n = i : r = i;
|
|
1242
|
+
}
|
|
1243
|
+
return St(Tt(J({
|
|
1244
|
+
...e,
|
|
1245
|
+
C: n
|
|
1246
|
+
})));
|
|
1247
|
+
}, Ot = {
|
|
1248
|
+
harmonypalette: [
|
|
1249
|
+
0,
|
|
1250
|
+
150,
|
|
1251
|
+
210
|
|
1252
|
+
],
|
|
1253
|
+
analogous: [
|
|
1254
|
+
-30,
|
|
1255
|
+
0,
|
|
1256
|
+
30
|
|
1257
|
+
],
|
|
1258
|
+
complementary: [0, 180],
|
|
1259
|
+
splitcomplementary: [
|
|
1260
|
+
0,
|
|
1261
|
+
150,
|
|
1262
|
+
210
|
|
1263
|
+
],
|
|
1264
|
+
triadic: [
|
|
1265
|
+
0,
|
|
1266
|
+
120,
|
|
1267
|
+
240
|
|
1268
|
+
],
|
|
1269
|
+
tetradic: [
|
|
1270
|
+
0,
|
|
1271
|
+
60,
|
|
1272
|
+
180,
|
|
1273
|
+
240
|
|
1274
|
+
],
|
|
1275
|
+
square: [
|
|
1276
|
+
0,
|
|
1277
|
+
90,
|
|
1278
|
+
180,
|
|
1279
|
+
270
|
|
1280
|
+
],
|
|
1281
|
+
accentedanalogous: [
|
|
1282
|
+
-30,
|
|
1283
|
+
0,
|
|
1284
|
+
30,
|
|
1285
|
+
180
|
|
1286
|
+
],
|
|
1287
|
+
doublesplitcomplementary: [
|
|
1288
|
+
0,
|
|
1289
|
+
30,
|
|
1290
|
+
150,
|
|
1291
|
+
180,
|
|
1292
|
+
210,
|
|
1293
|
+
330
|
|
1294
|
+
],
|
|
1295
|
+
ambiguous: [
|
|
1296
|
+
15,
|
|
1297
|
+
135,
|
|
1298
|
+
255
|
|
1299
|
+
]
|
|
1300
|
+
}, kt = [
|
|
1301
|
+
{
|
|
1302
|
+
match: (e) => e.includes("neutrallight") || e.includes("neutral") && e.includes("light"),
|
|
1303
|
+
apply: (e) => ({
|
|
1304
|
+
...e,
|
|
1305
|
+
L: .93,
|
|
1306
|
+
C: Math.min(e.C * .08, .015)
|
|
1307
|
+
})
|
|
1308
|
+
},
|
|
1309
|
+
{
|
|
1310
|
+
match: (e) => e.includes("neutraldark") || e.includes("neutral") && e.includes("dark"),
|
|
1311
|
+
apply: (e) => ({
|
|
1312
|
+
...e,
|
|
1313
|
+
L: .1,
|
|
1314
|
+
C: Math.min(e.C * .08, .015)
|
|
1315
|
+
})
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
match: (e) => e.includes("neutral"),
|
|
1319
|
+
apply: (e) => ({
|
|
1320
|
+
...e,
|
|
1321
|
+
L: .55,
|
|
1322
|
+
C: Math.min(e.C * .06, .012)
|
|
1323
|
+
})
|
|
1324
|
+
},
|
|
1325
|
+
{
|
|
1326
|
+
match: (e) => e.endsWith("shade") || e.includes("colorshade"),
|
|
1327
|
+
apply: (e) => ({
|
|
1328
|
+
...e,
|
|
1329
|
+
L: .3,
|
|
1330
|
+
C: e.C
|
|
1331
|
+
})
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
match: (e) => e.endsWith("dark"),
|
|
1335
|
+
apply: (e) => ({
|
|
1336
|
+
...e,
|
|
1337
|
+
L: .22,
|
|
1338
|
+
C: e.C
|
|
1339
|
+
})
|
|
1340
|
+
},
|
|
1341
|
+
{
|
|
1342
|
+
match: (e) => e.endsWith("light") || e.endsWith("tint"),
|
|
1343
|
+
apply: (e) => ({
|
|
1344
|
+
...e,
|
|
1345
|
+
L: .88,
|
|
1346
|
+
C: e.C * .5
|
|
1347
|
+
})
|
|
1348
|
+
},
|
|
1349
|
+
{
|
|
1350
|
+
match: (e) => e.startsWith("accent"),
|
|
1351
|
+
apply: (e) => ({
|
|
1352
|
+
...e,
|
|
1353
|
+
L: .62,
|
|
1354
|
+
C: Math.max(e.C, .22)
|
|
1355
|
+
})
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
match: (e) => e.startsWith("main") || e.startsWith("primary") || e.startsWith("brand"),
|
|
1359
|
+
apply: (e) => ({
|
|
1360
|
+
...e,
|
|
1361
|
+
L: .52,
|
|
1362
|
+
C: Math.max(e.C, .22)
|
|
1363
|
+
})
|
|
1364
|
+
},
|
|
1365
|
+
{
|
|
1366
|
+
match: (e) => e.startsWith("background") || e.startsWith("bg"),
|
|
1367
|
+
apply: (e) => ({
|
|
1368
|
+
...e,
|
|
1369
|
+
L: .97,
|
|
1370
|
+
C: Math.min(e.C * .08, .012)
|
|
1371
|
+
})
|
|
1372
|
+
},
|
|
1373
|
+
{
|
|
1374
|
+
match: (e) => e.startsWith("surface"),
|
|
1375
|
+
apply: (e) => ({
|
|
1376
|
+
...e,
|
|
1377
|
+
L: .91,
|
|
1378
|
+
C: Math.min(e.C * .18, .025)
|
|
1379
|
+
})
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
match: (e) => e.startsWith("foreground") || e.startsWith("text") || e.startsWith("on"),
|
|
1383
|
+
apply: (e) => ({
|
|
1384
|
+
...e,
|
|
1385
|
+
L: .18,
|
|
1386
|
+
C: Math.min(e.C * .12, .02)
|
|
1387
|
+
})
|
|
1388
|
+
}
|
|
1389
|
+
], At = (e, t, n) => {
|
|
1390
|
+
let r = e.toLowerCase().replace(/[^a-z]/g, "");
|
|
1391
|
+
if (n > 1) {
|
|
1392
|
+
if (r.includes("tintshade")) return Pt(t, n);
|
|
1393
|
+
if (r.includes("monochromatic")) return Nt(t, n);
|
|
1394
|
+
if (r.includes("tint") || r.includes("shade")) return Pt(t, n);
|
|
1395
|
+
let e = Ot[r];
|
|
1396
|
+
return e ? jt(t, e, n) : Mt(t, n);
|
|
1397
|
+
}
|
|
1398
|
+
for (let { match: e, apply: n } of kt) if (e(r)) return [Y(n(t))];
|
|
1399
|
+
return [Y({
|
|
1400
|
+
...t,
|
|
1401
|
+
L: .55,
|
|
1402
|
+
C: Math.max(t.C, .18)
|
|
1403
|
+
})];
|
|
1404
|
+
}, jt = (e, t, n) => Array.from({ length: n }, (n, r) => {
|
|
1405
|
+
let i = t[r % t.length], a = Math.floor(r / t.length) * .08;
|
|
1406
|
+
return Y({
|
|
1407
|
+
...e,
|
|
1408
|
+
L: q(e.L - a),
|
|
1409
|
+
H: (e.H + i + 360) % 360
|
|
1410
|
+
});
|
|
1411
|
+
}), Mt = (e, t) => Array.from({ length: t }, (n, r) => Y({
|
|
1412
|
+
...e,
|
|
1413
|
+
H: (e.H + 360 / t * r) % 360
|
|
1414
|
+
})), Nt = (e, t) => Array.from({ length: t }, (n, r) => {
|
|
1415
|
+
let i = r / Math.max(t - 1, 1);
|
|
1416
|
+
return Y({
|
|
1417
|
+
L: bt(.12, .94, i),
|
|
1418
|
+
C: e.C * q(1 - Math.abs(i - .45) ** 2.5),
|
|
1419
|
+
H: e.H
|
|
1420
|
+
});
|
|
1421
|
+
}), Pt = (e, t) => Array.from({ length: t }, (n, r) => {
|
|
1422
|
+
let i = r / Math.max(t - 1, 1);
|
|
1423
|
+
return Y({
|
|
1424
|
+
L: bt(.1, .96, i < .5 ? .5 * (i * 2) ** 1.6 : 1 - .5 * ((1 - i) * 2) ** 1.4),
|
|
1425
|
+
C: e.C * q(1 - ((i - .4) / .7) ** 2 * .6),
|
|
1426
|
+
H: e.H
|
|
1427
|
+
});
|
|
1428
|
+
}), Ft = /^#[0-9a-fA-F]{6}$/, It = (e) => {
|
|
1429
|
+
for (let t of e) if (Ft.test(t)) return t;
|
|
1430
|
+
return "#ff0000";
|
|
1431
|
+
}, Lt = (e) => Object.fromEntries(Object.entries(e).map(([e, t]) => [e, At(e, Dt(It(t)), t.length)])), Rt = (e) => {
|
|
1432
|
+
let { r: t, g: n, b: r } = xt(e);
|
|
1433
|
+
return {
|
|
1434
|
+
r: Math.round(t * 255),
|
|
1435
|
+
g: Math.round(n * 255),
|
|
1436
|
+
b: Math.round(r * 255)
|
|
1437
|
+
};
|
|
1438
|
+
}, zt = (e, t = 1) => {
|
|
1439
|
+
let { r: n, g: r, b: i } = Rt(e);
|
|
1440
|
+
return `rgba(${n}, ${r}, ${i}, ${t})`;
|
|
1441
|
+
}, X = (e) => {
|
|
1442
|
+
let { r: t, g: n, b: r } = xt(e);
|
|
1443
|
+
return .2126 * K(t) + .7152 * K(n) + .0722 * K(r);
|
|
1444
|
+
}, Bt = (e, t) => {
|
|
1445
|
+
let n = X(e), r = X(t);
|
|
1446
|
+
return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
|
|
1447
|
+
}, Vt = (e) => X(e) > .179 ? "#000000" : "#ffffff", Z = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4, Ht = (e) => e <= .0031308 ? 12.92 * e : 1.055 * e ** (1 / 2.4) - .055, Q = (e) => e < 0 ? 0 : e > 1 ? 1 : e, Ut = (e, t, n) => {
|
|
1448
|
+
let r = Z(e), i = Z(t), a = Z(n), o = Math.cbrt(.4122214708 * r + .5363325363 * i + .0514459929 * a), s = Math.cbrt(.2119034982 * r + .6806995451 * i + .1073969566 * a), c = Math.cbrt(.0883024619 * r + .2817188376 * i + .6299787005 * a);
|
|
1449
|
+
return {
|
|
1450
|
+
L: .2104542553 * o + .793617785 * s - .0040720468 * c,
|
|
1451
|
+
a: 1.9779984951 * o - 2.428592205 * s + .4505937099 * c,
|
|
1452
|
+
b: .0259040371 * o + .7827717662 * s - .808675766 * c
|
|
1453
|
+
};
|
|
1454
|
+
}, Wt = (e, t, n) => {
|
|
1455
|
+
let r = e + .3963377774 * t + .2158037573 * n, i = e - .1055613458 * t - .0638541728 * n, a = e - .0894841775 * t - 1.291485548 * n, o = r * r * r, s = i * i * i, c = a * a * a;
|
|
1456
|
+
return {
|
|
1457
|
+
r: Q(Ht(4.0767416621 * o - 3.3077115913 * s + .2309699292 * c)),
|
|
1458
|
+
g: Q(Ht(-1.2684380046 * o + 2.6097574011 * s - .3413193965 * c)),
|
|
1459
|
+
b: Q(Ht(-.0041960863 * o - .7034186147 * s + 1.707614701 * c))
|
|
1460
|
+
};
|
|
1461
|
+
}, Gt = (e) => {
|
|
1462
|
+
if (typeof e != "string") throw TypeError(`Color must be a string, got ${typeof e}: ${JSON.stringify(e)}`);
|
|
1463
|
+
let t = e.trim().replace(/^#/, "").toLowerCase();
|
|
1464
|
+
if (/^[0-9a-f]{3}$/.test(t)) return "#" + t[0] + t[0] + t[1] + t[1] + t[2] + t[2];
|
|
1465
|
+
if (/^[0-9a-f]{6}$/.test(t)) return "#" + t;
|
|
1466
|
+
throw RangeError(`Invalid hex color: "${e}" — expected "#rgb" or "#rrggbb"`);
|
|
1467
|
+
}, Kt = (e) => ({
|
|
1468
|
+
r: parseInt(e.slice(1, 3), 16) / 255,
|
|
1469
|
+
g: parseInt(e.slice(3, 5), 16) / 255,
|
|
1470
|
+
b: parseInt(e.slice(5, 7), 16) / 255
|
|
1471
|
+
}), qt = (e, t, n) => {
|
|
1472
|
+
let r = (e) => Math.round(Q(e) * 255).toString(16).padStart(2, "0");
|
|
1473
|
+
return `#${r(e)}${r(t)}${r(n)}`;
|
|
1474
|
+
}, Jt = (e) => {
|
|
1475
|
+
let { r: t, g: n, b: r } = Kt(e), i = Ut(t, n, r);
|
|
1476
|
+
return {
|
|
1477
|
+
L: i.L,
|
|
1478
|
+
C: Math.sqrt(i.a * i.a + i.b * i.b),
|
|
1479
|
+
H: (Math.atan2(i.b, i.a) * 180 / Math.PI + 360) % 360
|
|
1480
|
+
};
|
|
1481
|
+
}, Yt = (e, t, n) => {
|
|
1482
|
+
let r = n * Math.PI / 180, { r: i, g: a, b: o } = Wt(e, t * Math.cos(r), t * Math.sin(r));
|
|
1483
|
+
return qt(i, a, o);
|
|
1484
|
+
}, Xt = (e, t) => {
|
|
1485
|
+
let n = Math.abs(e - t) % 360;
|
|
1486
|
+
return n > 180 ? 360 - n : n;
|
|
1487
|
+
}, $ = (e, t) => {
|
|
1488
|
+
let n = (e) => {
|
|
1489
|
+
let { r: t, g: n, b: r } = Kt(Gt(e));
|
|
1490
|
+
return .2126 * Z(t) + .7152 * Z(n) + .0722 * Z(r);
|
|
1491
|
+
}, r = n(e), i = n(t);
|
|
1492
|
+
return (Math.max(r, i) + .05) / (Math.min(r, i) + .05);
|
|
1493
|
+
}, Zt = (e) => $(e, "#ffffff") >= $(e, "#111111") ? "#ffffff" : "#111111";
|
|
1494
|
+
function Qt(e, t = {}) {
|
|
1495
|
+
if (!Array.isArray(e) || e.length === 0) throw TypeError("palette must be a non-empty array of hex color strings");
|
|
1496
|
+
let n = {
|
|
1497
|
+
neutralChromaMax: t.neutralChromaMax ?? .06,
|
|
1498
|
+
mainLightnessMin: t.mainLightnessMin ?? .4,
|
|
1499
|
+
mainLightnessMax: t.mainLightnessMax ?? .72,
|
|
1500
|
+
shadeHueTolerance: t.shadeHueTolerance ?? 30,
|
|
1501
|
+
accentHueMin: t.accentHueMin ?? 100,
|
|
1502
|
+
derivedDarkL: t.derivedDarkL ?? .2,
|
|
1503
|
+
derivedDarkC: t.derivedDarkC ?? .035
|
|
1504
|
+
}, r = e.map((e) => {
|
|
1505
|
+
let t = Gt(e);
|
|
1506
|
+
return {
|
|
1507
|
+
hex: t,
|
|
1508
|
+
lch: Jt(t)
|
|
1509
|
+
};
|
|
1510
|
+
}), i = r.filter((e) => e.lch.C < n.neutralChromaMax), a = (i.length > 0 ? i : r).slice().sort((e, t) => t.lch.L - e.lch.L)[0], o = r.filter((e) => e.lch.L >= n.mainLightnessMin && e.lch.L <= n.mainLightnessMax), s = (o.length > 0 ? o : r).slice().sort((e, t) => t.lch.C - e.lch.C)[0], c = i.filter((e) => e.lch.L < .35 && e.hex !== a.hex), l, u;
|
|
1511
|
+
c.length > 0 ? (l = c.slice().sort((e, t) => e.lch.L - t.lch.L)[0].hex, u = !1) : (l = Yt(n.derivedDarkL, n.derivedDarkC, s.lch.H), u = !0);
|
|
1512
|
+
let d = /* @__PURE__ */ new Set([a.hex, s.hex]), f = r.filter((e) => !d.has(e.hex)), p, m = !1;
|
|
1513
|
+
if (f.length > 0) {
|
|
1514
|
+
let e = f.filter((e) => Xt(e.lch.H, s.lch.H) < n.shadeHueTolerance && e.lch.C > .1);
|
|
1515
|
+
p = (e.length > 0 ? e : f).slice().sort((e, t) => t.lch.C - e.lch.C)[0].hex;
|
|
1516
|
+
} else p = Yt(Math.max(.05, s.lch.L - .08), s.lch.C * .92, s.lch.H), m = !0;
|
|
1517
|
+
let ee = /* @__PURE__ */ new Set([
|
|
1518
|
+
a.hex,
|
|
1519
|
+
s.hex,
|
|
1520
|
+
p
|
|
1521
|
+
]), h = r.filter((e) => !ee.has(e.hex)), g, _ = !1;
|
|
1522
|
+
if (h.length > 0) {
|
|
1523
|
+
let e = h.filter((e) => Xt(e.lch.H, s.lch.H) >= n.accentHueMin);
|
|
1524
|
+
g = (e.length > 0 ? e : h).slice().sort((e, t) => t.lch.C - e.lch.C)[0].hex;
|
|
1525
|
+
} else g = Yt(.72, Math.min(s.lch.C, .18), (s.lch.H + 150) % 360), _ = !0;
|
|
1526
|
+
let v = (e, t, n, r, i = !1) => ({
|
|
1527
|
+
hex: r,
|
|
1528
|
+
role: e,
|
|
1529
|
+
label: t,
|
|
1530
|
+
weight: n,
|
|
1531
|
+
derived: i,
|
|
1532
|
+
lch: Jt(r),
|
|
1533
|
+
textColor: Zt(r),
|
|
1534
|
+
contrast: parseFloat($(r, a.hex).toFixed(2))
|
|
1535
|
+
});
|
|
1536
|
+
return {
|
|
1537
|
+
neutralLight: v("neutralLight", "Neutral Light", "60%", a.hex),
|
|
1538
|
+
neutralDark: v("neutralDark", "Neutral Dark", "—", l, u),
|
|
1539
|
+
mainColor: v("mainColor", "Main Color", "30%", s.hex),
|
|
1540
|
+
mainColorShade: v("mainColorShade", "Main Color Shade", "—", p, m),
|
|
1541
|
+
accentColor: v("accentColor", "Accent Color", "10%", g, _)
|
|
1542
|
+
};
|
|
1344
1543
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
],
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
}),
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
${o.map(
|
|
1367
|
-
([r, l]) => ` ${(n + "-" + r).padEnd(e)}: ${l};`
|
|
1368
|
-
).join(`
|
|
1369
|
-
`)}
|
|
1370
|
-
}`;
|
|
1371
|
-
};
|
|
1372
|
-
export {
|
|
1373
|
-
g0 as bestTextOn,
|
|
1374
|
-
f0 as generateAlgorithmic,
|
|
1375
|
-
M0 as generateContrastPalettes,
|
|
1376
|
-
b0 as generateDataVisuals,
|
|
1377
|
-
d0 as generateHarmonyPalettes,
|
|
1378
|
-
p0 as generateImagePalettes,
|
|
1379
|
-
L0 as generatePerceptualPalettes,
|
|
1380
|
-
x0 as generateRadiumColors,
|
|
1381
|
-
H0 as getContrastRatio,
|
|
1382
|
-
At as getLuminance,
|
|
1383
|
-
y0 as getReadableTextColor,
|
|
1384
|
-
h0 as hexToRgb,
|
|
1385
|
-
C0 as hexToRgba,
|
|
1386
|
-
A0 as select60_30_10,
|
|
1387
|
-
I0 as toCssVars,
|
|
1388
|
-
$0 as toHexArray,
|
|
1389
|
-
T0 as toObject,
|
|
1390
|
-
$t as wcagContrast
|
|
1544
|
+
var $t = (e) => [
|
|
1545
|
+
e.neutralLight.hex,
|
|
1546
|
+
e.neutralDark.hex,
|
|
1547
|
+
e.mainColor.hex,
|
|
1548
|
+
e.mainColorShade.hex,
|
|
1549
|
+
e.accentColor.hex
|
|
1550
|
+
], en = (e) => ({
|
|
1551
|
+
neutralLight: e.neutralLight.hex,
|
|
1552
|
+
neutralDark: e.neutralDark.hex,
|
|
1553
|
+
mainColor: e.mainColor.hex,
|
|
1554
|
+
mainColorShade: e.mainColorShade.hex,
|
|
1555
|
+
accentColor: e.accentColor.hex
|
|
1556
|
+
}), tn = (e, t = "--color") => {
|
|
1557
|
+
let n = [
|
|
1558
|
+
["neutral-light", e.neutralLight.hex],
|
|
1559
|
+
["neutral-dark", e.neutralDark.hex],
|
|
1560
|
+
["main", e.mainColor.hex],
|
|
1561
|
+
["main-shade", e.mainColorShade.hex],
|
|
1562
|
+
["accent", e.accentColor.hex]
|
|
1563
|
+
], r = Math.max(...n.map(([e]) => (t + "-" + e).length));
|
|
1564
|
+
return `:root {\n${n.map(([e, n]) => ` ${(t + "-" + e).padEnd(r)}: ${n};`).join("\n")}\n}`;
|
|
1391
1565
|
};
|
|
1566
|
+
export { Zt as bestTextOn, he as generateAlgorithmic, Ee as generateContrastPalettes, We as generateDataVisuals, qe as generateHarmonyPalettes, ut as generateImagePalettes, vt as generatePerceptualPalettes, Lt as generateRadiumColors, Bt as getContrastRatio, X as getLuminance, Vt as getReadableTextColor, Rt as hexToRgb, zt as hexToRgba, Qt as select60_30_10, tn as toCssVars, $t as toHexArray, en as toObject, $ as wcagContrast };
|