WPILibC++ 2024.3.2
Color.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include <algorithm>
8#include <stdexcept>
9#include <string>
10#include <string_view>
11
12#include <fmt/core.h>
13#include <gcem.hpp>
14#include <wpi/StringExtras.h>
15#include <wpi/ct_string.h>
16
17namespace frc {
18
19/**
20 * Represents colors that can be used with Addressable LEDs.
21 *
22 * Limited to 12 bits of precision.
23 */
24class Color {
25 public:
26 /*
27 * FIRST Colors
28 */
29
30 /**
31 * 0x1560BD.
32 */
33 static const Color kDenim;
34
35 /**
36 * 0x0066B3.
37 */
38 static const Color kFirstBlue;
39
40 /**
41 * 0xED1C24.
42 */
43 static const Color kFirstRed;
44
45 /*
46 * Standard Colors
47 */
48
49 /**
50 * 0xF0F8FF.
51 */
52 static const Color kAliceBlue;
53
54 /**
55 * 0xFAEBD7.
56 */
57 static const Color kAntiqueWhite;
58
59 /**
60 * 0x00FFFF.
61 */
62 static const Color kAqua;
63
64 /**
65 * 0x7FFFD4.
66 */
67 static const Color kAquamarine;
68
69 /**
70 * 0xF0FFFF.
71 */
72 static const Color kAzure;
73
74 /**
75 * 0xF5F5DC.
76 */
77 static const Color kBeige;
78
79 /**
80 * 0xFFE4C4.
81 */
82 static const Color kBisque;
83
84 /**
85 * 0x000000.
86 */
87 static const Color kBlack;
88
89 /**
90 * 0xFFEBCD.
91 */
92 static const Color kBlanchedAlmond;
93
94 /**
95 * 0x0000FF.
96 */
97 static const Color kBlue;
98
99 /**
100 * 0x8A2BE2.
101 */
102 static const Color kBlueViolet;
103
104 /**
105 * 0xA52A2A.
106 */
107 static const Color kBrown;
108
109 /**
110 * 0xDEB887.
111 */
112 static const Color kBurlywood;
113
114 /**
115 * 0x5F9EA0.
116 */
117 static const Color kCadetBlue;
118
119 /**
120 * 0x7FFF00.
121 */
122 static const Color kChartreuse;
123
124 /**
125 * 0xD2691E.
126 */
127 static const Color kChocolate;
128
129 /**
130 * 0xFF7F50.
131 */
132 static const Color kCoral;
133
134 /**
135 * 0x6495ED.
136 */
137 static const Color kCornflowerBlue;
138
139 /**
140 * 0xFFF8DC.
141 */
142 static const Color kCornsilk;
143
144 /**
145 * 0xDC143C.
146 */
147 static const Color kCrimson;
148
149 /**
150 * 0x00FFFF.
151 */
152 static const Color kCyan;
153
154 /**
155 * 0x00008B.
156 */
157 static const Color kDarkBlue;
158
159 /**
160 * 0x008B8B.
161 */
162 static const Color kDarkCyan;
163
164 /**
165 * 0xB8860B.
166 */
167 static const Color kDarkGoldenrod;
168
169 /**
170 * 0xA9A9A9.
171 */
172 static const Color kDarkGray;
173
174 /**
175 * 0x006400.
176 */
177 static const Color kDarkGreen;
178
179 /**
180 * 0xBDB76B.
181 */
182 static const Color kDarkKhaki;
183
184 /**
185 * 0x8B008B.
186 */
187 static const Color kDarkMagenta;
188
189 /**
190 * 0x556B2F.
191 */
192 static const Color kDarkOliveGreen;
193
194 /**
195 * 0xFF8C00.
196 */
197 static const Color kDarkOrange;
198
199 /**
200 * 0x9932CC.
201 */
202 static const Color kDarkOrchid;
203
204 /**
205 * 0x8B0000.
206 */
207 static const Color kDarkRed;
208
209 /**
210 * 0xE9967A.
211 */
212 static const Color kDarkSalmon;
213
214 /**
215 * 0x8FBC8F.
216 */
217 static const Color kDarkSeaGreen;
218
219 /**
220 * 0x483D8B.
221 */
222 static const Color kDarkSlateBlue;
223
224 /**
225 * 0x2F4F4F.
226 */
227 static const Color kDarkSlateGray;
228
229 /**
230 * 0x00CED1.
231 */
232 static const Color kDarkTurquoise;
233
234 /**
235 * 0x9400D3.
236 */
237 static const Color kDarkViolet;
238
239 /**
240 * 0xFF1493.
241 */
242 static const Color kDeepPink;
243
244 /**
245 * 0x00BFFF.
246 */
247 static const Color kDeepSkyBlue;
248
249 /**
250 * 0x696969.
251 */
252 static const Color kDimGray;
253
254 /**
255 * 0x1E90FF.
256 */
257 static const Color kDodgerBlue;
258
259 /**
260 * 0xB22222.
261 */
262 static const Color kFirebrick;
263
264 /**
265 * 0xFFFAF0.
266 */
267 static const Color kFloralWhite;
268
269 /**
270 * 0x228B22.
271 */
272 static const Color kForestGreen;
273
274 /**
275 * 0xFF00FF.
276 */
277 static const Color kFuchsia;
278
279 /**
280 * 0xDCDCDC.
281 */
282 static const Color kGainsboro;
283
284 /**
285 * 0xF8F8FF.
286 */
287 static const Color kGhostWhite;
288
289 /**
290 * 0xFFD700.
291 */
292 static const Color kGold;
293
294 /**
295 * 0xDAA520.
296 */
297 static const Color kGoldenrod;
298
299 /**
300 * 0x808080.
301 */
302 static const Color kGray;
303
304 /**
305 * 0x008000.
306 */
307 static const Color kGreen;
308
309 /**
310 * 0xADFF2F.
311 */
312 static const Color kGreenYellow;
313
314 /**
315 * 0xF0FFF0.
316 */
317 static const Color kHoneydew;
318
319 /**
320 * 0xFF69B4.
321 */
322 static const Color kHotPink;
323
324 /**
325 * 0xCD5C5C.
326 */
327 static const Color kIndianRed;
328
329 /**
330 * 0x4B0082.
331 */
332 static const Color kIndigo;
333
334 /**
335 * 0xFFFFF0.
336 */
337 static const Color kIvory;
338
339 /**
340 * 0xF0E68C.
341 */
342 static const Color kKhaki;
343
344 /**
345 * 0xE6E6FA.
346 */
347 static const Color kLavender;
348
349 /**
350 * 0xFFF0F5.
351 */
352 static const Color kLavenderBlush;
353
354 /**
355 * 0x7CFC00.
356 */
357 static const Color kLawnGreen;
358
359 /**
360 * 0xFFFACD.
361 */
362 static const Color kLemonChiffon;
363
364 /**
365 * 0xADD8E6.
366 */
367 static const Color kLightBlue;
368
369 /**
370 * 0xF08080.
371 */
372 static const Color kLightCoral;
373
374 /**
375 * 0xE0FFFF.
376 */
377 static const Color kLightCyan;
378
379 /**
380 * 0xFAFAD2.
381 */
383
384 /**
385 * 0xD3D3D3.
386 */
387 static const Color kLightGray;
388
389 /**
390 * 0x90EE90.
391 */
392 static const Color kLightGreen;
393
394 /**
395 * 0xFFB6C1.
396 */
397 static const Color kLightPink;
398
399 /**
400 * 0xFFA07A.
401 */
402 static const Color kLightSalmon;
403
404 /**
405 * 0x20B2AA.
406 */
407 static const Color kLightSeaGreen;
408
409 /**
410 * 0x87CEFA.
411 */
412 static const Color kLightSkyBlue;
413
414 /**
415 * 0x778899.
416 */
417 static const Color kLightSlateGray;
418
419 /**
420 * 0xB0C4DE.
421 */
422 static const Color kLightSteelBlue;
423
424 /**
425 * 0xFFFFE0.
426 */
427 static const Color kLightYellow;
428
429 /**
430 * 0x00FF00.
431 */
432 static const Color kLime;
433
434 /**
435 * 0x32CD32.
436 */
437 static const Color kLimeGreen;
438
439 /**
440 * 0xFAF0E6.
441 */
442 static const Color kLinen;
443
444 /**
445 * 0xFF00FF.
446 */
447 static const Color kMagenta;
448
449 /**
450 * 0x800000.
451 */
452 static const Color kMaroon;
453
454 /**
455 * 0x66CDAA.
456 */
458
459 /**
460 * 0x0000CD.
461 */
462 static const Color kMediumBlue;
463
464 /**
465 * 0xBA55D3.
466 */
467 static const Color kMediumOrchid;
468
469 /**
470 * 0x9370DB.
471 */
472 static const Color kMediumPurple;
473
474 /**
475 * 0x3CB371.
476 */
477 static const Color kMediumSeaGreen;
478
479 /**
480 * 0x7B68EE.
481 */
483
484 /**
485 * 0x00FA9A.
486 */
488
489 /**
490 * 0x48D1CC.
491 */
493
494 /**
495 * 0xC71585.
496 */
498
499 /**
500 * 0x191970.
501 */
502 static const Color kMidnightBlue;
503
504 /**
505 * 0xF5FFFA.
506 */
507 static const Color kMintcream;
508
509 /**
510 * 0xFFE4E1.
511 */
512 static const Color kMistyRose;
513
514 /**
515 * 0xFFE4B5.
516 */
517 static const Color kMoccasin;
518
519 /**
520 * 0xFFDEAD.
521 */
522 static const Color kNavajoWhite;
523
524 /**
525 * 0x000080.
526 */
527 static const Color kNavy;
528
529 /**
530 * 0xFDF5E6.
531 */
532 static const Color kOldLace;
533
534 /**
535 * 0x808000.
536 */
537 static const Color kOlive;
538
539 /**
540 * 0x6B8E23.
541 */
542 static const Color kOliveDrab;
543
544 /**
545 * 0xFFA500.
546 */
547 static const Color kOrange;
548
549 /**
550 * 0xFF4500.
551 */
552 static const Color kOrangeRed;
553
554 /**
555 * 0xDA70D6.
556 */
557 static const Color kOrchid;
558
559 /**
560 * 0xEEE8AA.
561 */
562 static const Color kPaleGoldenrod;
563
564 /**
565 * 0x98FB98.
566 */
567 static const Color kPaleGreen;
568
569 /**
570 * 0xAFEEEE.
571 */
572 static const Color kPaleTurquoise;
573
574 /**
575 * 0xDB7093.
576 */
577 static const Color kPaleVioletRed;
578
579 /**
580 * 0xFFEFD5.
581 */
582 static const Color kPapayaWhip;
583
584 /**
585 * 0xFFDAB9.
586 */
587 static const Color kPeachPuff;
588
589 /**
590 * 0xCD853F.
591 */
592 static const Color kPeru;
593
594 /**
595 * 0xFFC0CB.
596 */
597 static const Color kPink;
598
599 /**
600 * 0xDDA0DD.
601 */
602 static const Color kPlum;
603
604 /**
605 * 0xB0E0E6.
606 */
607 static const Color kPowderBlue;
608
609 /**
610 * 0x800080.
611 */
612 static const Color kPurple;
613
614 /**
615 * 0xFF0000.
616 */
617 static const Color kRed;
618
619 /**
620 * 0xBC8F8F.
621 */
622 static const Color kRosyBrown;
623
624 /**
625 * 0x4169E1.
626 */
627 static const Color kRoyalBlue;
628
629 /**
630 * 0x8B4513.
631 */
632 static const Color kSaddleBrown;
633
634 /**
635 * 0xFA8072.
636 */
637 static const Color kSalmon;
638
639 /**
640 * 0xF4A460.
641 */
642 static const Color kSandyBrown;
643
644 /**
645 * 0x2E8B57.
646 */
647 static const Color kSeaGreen;
648
649 /**
650 * 0xFFF5EE.
651 */
652 static const Color kSeashell;
653
654 /**
655 * 0xA0522D.
656 */
657 static const Color kSienna;
658
659 /**
660 * 0xC0C0C0.
661 */
662 static const Color kSilver;
663
664 /**
665 * 0x87CEEB.
666 */
667 static const Color kSkyBlue;
668
669 /**
670 * 0x6A5ACD.
671 */
672 static const Color kSlateBlue;
673
674 /**
675 * 0x708090.
676 */
677 static const Color kSlateGray;
678
679 /**
680 * 0xFFFAFA.
681 */
682 static const Color kSnow;
683
684 /**
685 * 0x00FF7F.
686 */
687 static const Color kSpringGreen;
688
689 /**
690 * 0x4682B4.
691 */
692 static const Color kSteelBlue;
693
694 /**
695 * 0xD2B48C.
696 */
697 static const Color kTan;
698
699 /**
700 * 0x008080.
701 */
702 static const Color kTeal;
703
704 /**
705 * 0xD8BFD8.
706 */
707 static const Color kThistle;
708
709 /**
710 * 0xFF6347.
711 */
712 static const Color kTomato;
713
714 /**
715 * 0x40E0D0.
716 */
717 static const Color kTurquoise;
718
719 /**
720 * 0xEE82EE.
721 */
722 static const Color kViolet;
723
724 /**
725 * 0xF5DEB3.
726 */
727 static const Color kWheat;
728
729 /**
730 * 0xFFFFFF.
731 */
732 static const Color kWhite;
733
734 /**
735 * 0xF5F5F5.
736 */
737 static const Color kWhiteSmoke;
738
739 /**
740 * 0xFFFF00.
741 */
742 static const Color kYellow;
743
744 /**
745 * 0x9ACD32.
746 */
747 static const Color kYellowGreen;
748
749 /**
750 * Constructs a default color (black).
751 */
752 constexpr Color() = default;
753
754 /**
755 * Constructs a Color from doubles (0-1).
756 *
757 * @param r Red value (0-1)
758 * @param g Green value (0-1)
759 * @param b Blue value (0-1)
760 */
761 constexpr Color(double r, double g, double b)
762 : red(roundAndClamp(r)),
763 green(roundAndClamp(g)),
764 blue(roundAndClamp(b)) {}
765
766 /**
767 * Constructs a Color from ints (0-255).
768 *
769 * @param r Red value (0-255)
770 * @param g Green value (0-255)
771 * @param b Blue value (0-255)
772 */
773 constexpr Color(int r, int g, int b)
774 : Color(r / 255.0, g / 255.0, b / 255.0) {}
775
776 /**
777 * Constructs a Color from a hex string.
778 *
779 * @param hexString a string of the format <tt>\#RRGGBB</tt>
780 * @throws std::invalid_argument if the hex string is invalid.
781 */
782 explicit constexpr Color(std::string_view hexString) {
783 if (hexString.length() != 7 || !hexString.starts_with("#") ||
784 !wpi::isHexDigit(hexString[1]) || !wpi::isHexDigit(hexString[2]) ||
785 !wpi::isHexDigit(hexString[3]) || !wpi::isHexDigit(hexString[4]) ||
786 !wpi::isHexDigit(hexString[5]) || !wpi::isHexDigit(hexString[6])) {
787 throw std::invalid_argument(
788 fmt::format("Invalid hex string for Color \"{}\"", hexString));
789 }
790
791 int r = wpi::hexDigitValue(hexString[1]) * 16 +
792 wpi::hexDigitValue(hexString[2]);
793 int g = wpi::hexDigitValue(hexString[3]) * 16 +
794 wpi::hexDigitValue(hexString[4]);
795 int b = wpi::hexDigitValue(hexString[5]) * 16 +
796 wpi::hexDigitValue(hexString[6]);
797
798 red = r / 255.0;
799 green = g / 255.0;
800 blue = b / 255.0;
801 }
802
803 constexpr bool operator==(const Color&) const = default;
804
805 /**
806 * Creates a Color from HSV values.
807 *
808 * @param h The h value [0-180)
809 * @param s The s value [0-255]
810 * @param v The v value [0-255]
811 * @return The color
812 */
813 static constexpr Color FromHSV(int h, int s, int v) {
814 // Loosely based on
815 // https://en.wikipedia.org/wiki/HSL_and_HSV#HSV_to_RGB
816 // The hue range is split into 60 degree regions where in each region there
817 // is one rgb component at a low value (m), one at a high value (v) and one
818 // that changes (X) from low to high (X+m) or high to low (v-X)
819
820 // Difference between highest and lowest value of any rgb component
821 int chroma = (s * v) >> 8;
822
823 // Because hue is 0-180 rather than 0-360 use 30 not 60
824 int region = (h / 30) % 6;
825
826 // Remainder converted from 0-30 to 0-255
827 int remainder = static_cast<int>((h % 30) * (255 / 30.0));
828
829 // Value of the lowest rgb component
830 int m = v - chroma;
831
832 // Goes from 0 to chroma as hue increases
833 int X = (chroma * remainder) >> 8;
834
835 switch (region) {
836 case 0:
837 return Color(v, X + m, m);
838 case 1:
839 return Color(v - X, v, m);
840 case 2:
841 return Color(m, v, X + m);
842 case 3:
843 return Color(m, v - X, v);
844 case 4:
845 return Color(X + m, m, v);
846 default:
847 return Color(v, m, v - X);
848 }
849 }
850
851 /**
852 * Return this color represented as a hex string.
853 *
854 * @return a string of the format <tt>\#RRGGBB</tt>
855 */
856 constexpr auto HexString() const {
857 const int r = 255.0 * red;
858 const int g = 255.0 * green;
859 const int b = 255.0 * blue;
860
862 {'#', wpi::hexdigit(r / 16), wpi::hexdigit(r % 16),
863 wpi::hexdigit(g / 16), wpi::hexdigit(g % 16), wpi::hexdigit(b / 16),
864 wpi::hexdigit(b % 16)}};
865 }
866
867 /// Red component (0-1).
868 double red = 0.0;
869
870 /// Green component (0-1).
871 double green = 0.0;
872
873 /// Blue component (0-1).
874 double blue = 0.0;
875
876 private:
877 static constexpr double roundAndClamp(double value) {
878 return std::clamp(gcem::ceil(value * (1 << 12)) / (1 << 12), 0.0, 1.0);
879 }
880};
881
882/*
883 * FIRST Colors
884 */
885inline constexpr Color Color::kDenim{0.0823529412, 0.376470589, 0.7411764706};
886inline constexpr Color Color::kFirstBlue{0.0, 0.4, 0.7019607844};
887inline constexpr Color Color::kFirstRed{0.9294117648, 0.1098039216,
888 0.1411764706};
889
890/*
891 * Standard Colors
892 */
893inline constexpr Color Color::kAliceBlue{0.9411765f, 0.972549f, 1.0f};
894inline constexpr Color Color::kAntiqueWhite{0.98039216f, 0.92156863f,
895 0.84313726f};
896inline constexpr Color Color::kAqua{0.0f, 1.0f, 1.0f};
897inline constexpr Color Color::kAquamarine{0.49803922f, 1.0f, 0.83137256f};
898inline constexpr Color Color::kAzure{0.9411765f, 1.0f, 1.0f};
899inline constexpr Color Color::kBeige{0.9607843f, 0.9607843f, 0.8627451f};
900inline constexpr Color Color::kBisque{1.0f, 0.89411765f, 0.76862746f};
901inline constexpr Color Color::kBlack{0.0f, 0.0f, 0.0f};
902inline constexpr Color Color::kBlanchedAlmond{1.0f, 0.92156863f, 0.8039216f};
903inline constexpr Color Color::kBlue{0.0f, 0.0f, 1.0f};
904inline constexpr Color Color::kBlueViolet{0.5411765f, 0.16862746f, 0.8862745f};
905inline constexpr Color Color::kBrown{0.64705884f, 0.16470589f, 0.16470589f};
906inline constexpr Color Color::kBurlywood{0.87058824f, 0.72156864f, 0.5294118f};
907inline constexpr Color Color::kCadetBlue{0.37254903f, 0.61960787f, 0.627451f};
908inline constexpr Color Color::kChartreuse{0.49803922f, 1.0f, 0.0f};
909inline constexpr Color Color::kChocolate{0.8235294f, 0.4117647f, 0.11764706f};
910inline constexpr Color Color::kCoral{1.0f, 0.49803922f, 0.3137255f};
911inline constexpr Color Color::kCornflowerBlue{0.39215687f, 0.58431375f,
912 0.92941177f};
913inline constexpr Color Color::kCornsilk{1.0f, 0.972549f, 0.8627451f};
914inline constexpr Color Color::kCrimson{0.8627451f, 0.078431375f, 0.23529412f};
915inline constexpr Color Color::kCyan{0.0f, 1.0f, 1.0f};
916inline constexpr Color Color::kDarkBlue{0.0f, 0.0f, 0.54509807f};
917inline constexpr Color Color::kDarkCyan{0.0f, 0.54509807f, 0.54509807f};
918inline constexpr Color Color::kDarkGoldenrod{0.72156864f, 0.5254902f,
919 0.043137256f};
920inline constexpr Color Color::kDarkGray{0.6627451f, 0.6627451f, 0.6627451f};
921inline constexpr Color Color::kDarkGreen{0.0f, 0.39215687f, 0.0f};
922inline constexpr Color Color::kDarkKhaki{0.7411765f, 0.7176471f, 0.41960785f};
923inline constexpr Color Color::kDarkMagenta{0.54509807f, 0.0f, 0.54509807f};
924inline constexpr Color Color::kDarkOliveGreen{0.33333334f, 0.41960785f,
925 0.18431373f};
926inline constexpr Color Color::kDarkOrange{1.0f, 0.54901963f, 0.0f};
927inline constexpr Color Color::kDarkOrchid{0.6f, 0.19607843f, 0.8f};
928inline constexpr Color Color::kDarkRed{0.54509807f, 0.0f, 0.0f};
929inline constexpr Color Color::kDarkSalmon{0.9137255f, 0.5882353f, 0.47843137f};
930inline constexpr Color Color::kDarkSeaGreen{0.56078434f, 0.7372549f,
931 0.56078434f};
932inline constexpr Color Color::kDarkSlateBlue{0.28235295f, 0.23921569f,
933 0.54509807f};
934inline constexpr Color Color::kDarkSlateGray{0.18431373f, 0.30980393f,
935 0.30980393f};
936inline constexpr Color Color::kDarkTurquoise{0.0f, 0.80784315f, 0.81960785f};
937inline constexpr Color Color::kDarkViolet{0.5803922f, 0.0f, 0.827451f};
938inline constexpr Color Color::kDeepPink{1.0f, 0.078431375f, 0.5764706f};
939inline constexpr Color Color::kDeepSkyBlue{0.0f, 0.7490196f, 1.0f};
940inline constexpr Color Color::kDimGray{0.4117647f, 0.4117647f, 0.4117647f};
941inline constexpr Color Color::kDodgerBlue{0.11764706f, 0.5647059f, 1.0f};
942inline constexpr Color Color::kFirebrick{0.69803923f, 0.13333334f, 0.13333334f};
943inline constexpr Color Color::kFloralWhite{1.0f, 0.98039216f, 0.9411765f};
944inline constexpr Color Color::kForestGreen{0.13333334f, 0.54509807f,
945 0.13333334f};
946inline constexpr Color Color::kFuchsia{1.0f, 0.0f, 1.0f};
947inline constexpr Color Color::kGainsboro{0.8627451f, 0.8627451f, 0.8627451f};
948inline constexpr Color Color::kGhostWhite{0.972549f, 0.972549f, 1.0f};
949inline constexpr Color Color::kGold{1.0f, 0.84313726f, 0.0f};
950inline constexpr Color Color::kGoldenrod{0.85490197f, 0.64705884f, 0.1254902f};
951inline constexpr Color Color::kGray{0.5019608f, 0.5019608f, 0.5019608f};
952inline constexpr Color Color::kGreen{0.0f, 0.5019608f, 0.0f};
953inline constexpr Color Color::kGreenYellow{0.6784314f, 1.0f, 0.18431373f};
954inline constexpr Color Color::kHoneydew{0.9411765f, 1.0f, 0.9411765f};
955inline constexpr Color Color::kHotPink{1.0f, 0.4117647f, 0.7058824f};
956inline constexpr Color Color::kIndianRed{0.8039216f, 0.36078432f, 0.36078432f};
957inline constexpr Color Color::kIndigo{0.29411766f, 0.0f, 0.50980395f};
958inline constexpr Color Color::kIvory{1.0f, 1.0f, 0.9411765f};
959inline constexpr Color Color::kKhaki{0.9411765f, 0.9019608f, 0.54901963f};
960inline constexpr Color Color::kLavender{0.9019608f, 0.9019608f, 0.98039216f};
961inline constexpr Color Color::kLavenderBlush{1.0f, 0.9411765f, 0.9607843f};
962inline constexpr Color Color::kLawnGreen{0.4862745f, 0.9882353f, 0.0f};
963inline constexpr Color Color::kLemonChiffon{1.0f, 0.98039216f, 0.8039216f};
964inline constexpr Color Color::kLightBlue{0.6784314f, 0.84705883f, 0.9019608f};
965inline constexpr Color Color::kLightCoral{0.9411765f, 0.5019608f, 0.5019608f};
966inline constexpr Color Color::kLightCyan{0.8784314f, 1.0f, 1.0f};
967inline constexpr Color Color::kLightGoldenrodYellow{0.98039216f, 0.98039216f,
968 0.8235294f};
969inline constexpr Color Color::kLightGray{0.827451f, 0.827451f, 0.827451f};
970inline constexpr Color Color::kLightGreen{0.5647059f, 0.93333334f, 0.5647059f};
971inline constexpr Color Color::kLightPink{1.0f, 0.7137255f, 0.75686276f};
972inline constexpr Color Color::kLightSalmon{1.0f, 0.627451f, 0.47843137f};
973inline constexpr Color Color::kLightSeaGreen{0.1254902f, 0.69803923f,
974 0.6666667f};
975inline constexpr Color Color::kLightSkyBlue{0.5294118f, 0.80784315f,
976 0.98039216f};
977inline constexpr Color Color::kLightSlateGray{0.46666667f, 0.53333336f, 0.6f};
978inline constexpr Color Color::kLightSteelBlue{0.6901961f, 0.76862746f,
979 0.87058824f};
980inline constexpr Color Color::kLightYellow{1.0f, 1.0f, 0.8784314f};
981inline constexpr Color Color::kLime{0.0f, 1.0f, 0.0f};
982inline constexpr Color Color::kLimeGreen{0.19607843f, 0.8039216f, 0.19607843f};
983inline constexpr Color Color::kLinen{0.98039216f, 0.9411765f, 0.9019608f};
984inline constexpr Color Color::kMagenta{1.0f, 0.0f, 1.0f};
985inline constexpr Color Color::kMaroon{0.5019608f, 0.0f, 0.0f};
986inline constexpr Color Color::kMediumAquamarine{0.4f, 0.8039216f, 0.6666667f};
987inline constexpr Color Color::kMediumBlue{0.0f, 0.0f, 0.8039216f};
988inline constexpr Color Color::kMediumOrchid{0.7294118f, 0.33333334f, 0.827451f};
989inline constexpr Color Color::kMediumPurple{0.5764706f, 0.4392157f,
990 0.85882354f};
991inline constexpr Color Color::kMediumSeaGreen{0.23529412f, 0.7019608f,
992 0.44313726f};
993inline constexpr Color Color::kMediumSlateBlue{0.48235294f, 0.40784314f,
994 0.93333334f};
995inline constexpr Color Color::kMediumSpringGreen{0.0f, 0.98039216f, 0.6039216f};
996inline constexpr Color Color::kMediumTurquoise{0.28235295f, 0.81960785f, 0.8f};
997inline constexpr Color Color::kMediumVioletRed{0.78039217f, 0.08235294f,
998 0.52156866f};
999inline constexpr Color Color::kMidnightBlue{0.09803922f, 0.09803922f,
1000 0.4392157f};
1001inline constexpr Color Color::kMintcream{0.9607843f, 1.0f, 0.98039216f};
1002inline constexpr Color Color::kMistyRose{1.0f, 0.89411765f, 0.88235295f};
1003inline constexpr Color Color::kMoccasin{1.0f, 0.89411765f, 0.70980394f};
1004inline constexpr Color Color::kNavajoWhite{1.0f, 0.87058824f, 0.6784314f};
1005inline constexpr Color Color::kNavy{0.0f, 0.0f, 0.5019608f};
1006inline constexpr Color Color::kOldLace{0.99215686f, 0.9607843f, 0.9019608f};
1007inline constexpr Color Color::kOlive{0.5019608f, 0.5019608f, 0.0f};
1008inline constexpr Color Color::kOliveDrab{0.41960785f, 0.5568628f, 0.13725491f};
1009inline constexpr Color Color::kOrange{1.0f, 0.64705884f, 0.0f};
1010inline constexpr Color Color::kOrangeRed{1.0f, 0.27058825f, 0.0f};
1011inline constexpr Color Color::kOrchid{0.85490197f, 0.4392157f, 0.8392157f};
1012inline constexpr Color Color::kPaleGoldenrod{0.93333334f, 0.9098039f,
1013 0.6666667f};
1014inline constexpr Color Color::kPaleGreen{0.59607846f, 0.9843137f, 0.59607846f};
1015inline constexpr Color Color::kPaleTurquoise{0.6862745f, 0.93333334f,
1016 0.93333334f};
1017inline constexpr Color Color::kPaleVioletRed{0.85882354f, 0.4392157f,
1018 0.5764706f};
1019inline constexpr Color Color::kPapayaWhip{1.0f, 0.9372549f, 0.8352941f};
1020inline constexpr Color Color::kPeachPuff{1.0f, 0.85490197f, 0.7254902f};
1021inline constexpr Color Color::kPeru{0.8039216f, 0.52156866f, 0.24705882f};
1022inline constexpr Color Color::kPink{1.0f, 0.7529412f, 0.79607844f};
1023inline constexpr Color Color::kPlum{0.8666667f, 0.627451f, 0.8666667f};
1024inline constexpr Color Color::kPowderBlue{0.6901961f, 0.8784314f, 0.9019608f};
1025inline constexpr Color Color::kPurple{0.5019608f, 0.0f, 0.5019608f};
1026inline constexpr Color Color::kRed{1.0f, 0.0f, 0.0f};
1027inline constexpr Color Color::kRosyBrown{0.7372549f, 0.56078434f, 0.56078434f};
1028inline constexpr Color Color::kRoyalBlue{0.25490198f, 0.4117647f, 0.88235295f};
1029inline constexpr Color Color::kSaddleBrown{0.54509807f, 0.27058825f,
1030 0.07450981f};
1031inline constexpr Color Color::kSalmon{0.98039216f, 0.5019608f, 0.44705883f};
1032inline constexpr Color Color::kSandyBrown{0.95686275f, 0.6431373f, 0.3764706f};
1033inline constexpr Color Color::kSeaGreen{0.18039216f, 0.54509807f, 0.34117648f};
1034inline constexpr Color Color::kSeashell{1.0f, 0.9607843f, 0.93333334f};
1035inline constexpr Color Color::kSienna{0.627451f, 0.32156864f, 0.1764706f};
1036inline constexpr Color Color::kSilver{0.7529412f, 0.7529412f, 0.7529412f};
1037inline constexpr Color Color::kSkyBlue{0.5294118f, 0.80784315f, 0.92156863f};
1038inline constexpr Color Color::kSlateBlue{0.41568628f, 0.3529412f, 0.8039216f};
1039inline constexpr Color Color::kSlateGray{0.4392157f, 0.5019608f, 0.5647059f};
1040inline constexpr Color Color::kSnow{1.0f, 0.98039216f, 0.98039216f};
1041inline constexpr Color Color::kSpringGreen{0.0f, 1.0f, 0.49803922f};
1042inline constexpr Color Color::kSteelBlue{0.27450982f, 0.50980395f, 0.7058824f};
1043inline constexpr Color Color::kTan{0.8235294f, 0.7058824f, 0.54901963f};
1044inline constexpr Color Color::kTeal{0.0f, 0.5019608f, 0.5019608f};
1045inline constexpr Color Color::kThistle{0.84705883f, 0.7490196f, 0.84705883f};
1046inline constexpr Color Color::kTomato{1.0f, 0.3882353f, 0.2784314f};
1047inline constexpr Color Color::kTurquoise{0.2509804f, 0.8784314f, 0.8156863f};
1048inline constexpr Color Color::kViolet{0.93333334f, 0.50980395f, 0.93333334f};
1049inline constexpr Color Color::kWheat{0.9607843f, 0.87058824f, 0.7019608f};
1050inline constexpr Color Color::kWhite{1.0f, 1.0f, 1.0f};
1051inline constexpr Color Color::kWhiteSmoke{0.9607843f, 0.9607843f, 0.9607843f};
1052inline constexpr Color Color::kYellow{1.0f, 1.0f, 0.0f};
1053inline constexpr Color Color::kYellowGreen{0.6039216f, 0.8039216f, 0.19607843f};
1054
1055} // namespace frc
Represents colors that can be used with Addressable LEDs.
Definition: Color.h:24
static const Color kOrchid
0xDA70D6.
Definition: Color.h:557
constexpr bool operator==(const Color &) const =default
static const Color kYellowGreen
0x9ACD32.
Definition: Color.h:747
static const Color kViolet
0xEE82EE.
Definition: Color.h:722
static const Color kOliveDrab
0x6B8E23.
Definition: Color.h:542
static const Color kGreen
0x008000.
Definition: Color.h:307
constexpr Color(int r, int g, int b)
Constructs a Color from ints (0-255).
Definition: Color.h:773
static const Color kDarkTurquoise
0x00CED1.
Definition: Color.h:232
static const Color kDenim
0x1560BD.
Definition: Color.h:33
static const Color kMistyRose
0xFFE4E1.
Definition: Color.h:512
static const Color kGold
0xFFD700.
Definition: Color.h:292
static const Color kPaleVioletRed
0xDB7093.
Definition: Color.h:577
static const Color kDodgerBlue
0x1E90FF.
Definition: Color.h:257
static const Color kMoccasin
0xFFE4B5.
Definition: Color.h:517
static const Color kDarkCyan
0x008B8B.
Definition: Color.h:162
double green
Green component (0-1).
Definition: Color.h:871
static const Color kAliceBlue
0xF0F8FF.
Definition: Color.h:52
static const Color kDarkRed
0x8B0000.
Definition: Color.h:207
constexpr Color()=default
Constructs a default color (black).
static const Color kBlanchedAlmond
0xFFEBCD.
Definition: Color.h:92
static const Color kTeal
0x008080.
Definition: Color.h:702
static const Color kOrangeRed
0xFF4500.
Definition: Color.h:552
static const Color kFirebrick
0xB22222.
Definition: Color.h:262
static const Color kMediumVioletRed
0xC71585.
Definition: Color.h:497
static const Color kRosyBrown
0xBC8F8F.
Definition: Color.h:622
static const Color kDarkViolet
0x9400D3.
Definition: Color.h:237
static const Color kLightGreen
0x90EE90.
Definition: Color.h:392
static const Color kDimGray
0x696969.
Definition: Color.h:252
static const Color kPaleGreen
0x98FB98.
Definition: Color.h:567
static const Color kDarkOrchid
0x9932CC.
Definition: Color.h:202
static const Color kLightSkyBlue
0x87CEFA.
Definition: Color.h:412
static const Color kOldLace
0xFDF5E6.
Definition: Color.h:532
static const Color kLavenderBlush
0xFFF0F5.
Definition: Color.h:352
static const Color kMediumPurple
0x9370DB.
Definition: Color.h:472
static const Color kPurple
0x800080.
Definition: Color.h:612
static const Color kSnow
0xFFFAFA.
Definition: Color.h:682
static const Color kBlueViolet
0x8A2BE2.
Definition: Color.h:102
static const Color kGray
0x808080.
Definition: Color.h:302
static const Color kCoral
0xFF7F50.
Definition: Color.h:132
static const Color kAntiqueWhite
0xFAEBD7.
Definition: Color.h:57
static const Color kLightCoral
0xF08080.
Definition: Color.h:372
static const Color kPlum
0xDDA0DD.
Definition: Color.h:602
static const Color kTan
0xD2B48C.
Definition: Color.h:697
constexpr Color(double r, double g, double b)
Constructs a Color from doubles (0-1).
Definition: Color.h:761
static const Color kLightSalmon
0xFFA07A.
Definition: Color.h:402
static constexpr Color FromHSV(int h, int s, int v)
Creates a Color from HSV values.
Definition: Color.h:813
static const Color kMediumSpringGreen
0x00FA9A.
Definition: Color.h:487
static const Color kRed
0xFF0000.
Definition: Color.h:617
static const Color kBlack
0x000000.
Definition: Color.h:87
static const Color kLightSlateGray
0x778899.
Definition: Color.h:417
static const Color kKhaki
0xF0E68C.
Definition: Color.h:342
static const Color kIvory
0xFFFFF0.
Definition: Color.h:337
static const Color kDarkOrange
0xFF8C00.
Definition: Color.h:197
static const Color kSeashell
0xFFF5EE.
Definition: Color.h:652
static const Color kMediumAquamarine
0x66CDAA.
Definition: Color.h:457
static const Color kAzure
0xF0FFFF.
Definition: Color.h:72
static const Color kBlue
0x0000FF.
Definition: Color.h:97
static const Color kMediumSlateBlue
0x7B68EE.
Definition: Color.h:482
static const Color kMediumBlue
0x0000CD.
Definition: Color.h:462
static const Color kLightSteelBlue
0xB0C4DE.
Definition: Color.h:422
static const Color kPeachPuff
0xFFDAB9.
Definition: Color.h:587
static const Color kSpringGreen
0x00FF7F.
Definition: Color.h:687
static const Color kSalmon
0xFA8072.
Definition: Color.h:637
static const Color kHoneydew
0xF0FFF0.
Definition: Color.h:317
static const Color kTurquoise
0x40E0D0.
Definition: Color.h:717
static const Color kSlateGray
0x708090.
Definition: Color.h:677
double red
Red component (0-1).
Definition: Color.h:868
static const Color kLemonChiffon
0xFFFACD.
Definition: Color.h:362
static const Color kPaleGoldenrod
0xEEE8AA.
Definition: Color.h:562
static const Color kDeepPink
0xFF1493.
Definition: Color.h:242
static const Color kRoyalBlue
0x4169E1.
Definition: Color.h:627
static const Color kForestGreen
0x228B22.
Definition: Color.h:272
static const Color kLavender
0xE6E6FA.
Definition: Color.h:347
double blue
Blue component (0-1).
Definition: Color.h:874
static const Color kIndigo
0x4B0082.
Definition: Color.h:332
static const Color kHotPink
0xFF69B4.
Definition: Color.h:322
static const Color kFirstBlue
0x0066B3.
Definition: Color.h:38
static const Color kLightSeaGreen
0x20B2AA.
Definition: Color.h:407
static const Color kDarkGreen
0x006400.
Definition: Color.h:177
static const Color kFuchsia
0xFF00FF.
Definition: Color.h:277
static const Color kGreenYellow
0xADFF2F.
Definition: Color.h:312
static const Color kTomato
0xFF6347.
Definition: Color.h:712
static const Color kDarkSalmon
0xE9967A.
Definition: Color.h:212
static const Color kMediumOrchid
0xBA55D3.
Definition: Color.h:467
static const Color kDarkMagenta
0x8B008B.
Definition: Color.h:187
static const Color kDarkGoldenrod
0xB8860B.
Definition: Color.h:167
static const Color kDarkSlateGray
0x2F4F4F.
Definition: Color.h:227
static const Color kMintcream
0xF5FFFA.
Definition: Color.h:507
static const Color kMidnightBlue
0x191970.
Definition: Color.h:502
static const Color kCrimson
0xDC143C.
Definition: Color.h:147
static const Color kBisque
0xFFE4C4.
Definition: Color.h:82
static const Color kLightBlue
0xADD8E6.
Definition: Color.h:367
static const Color kBrown
0xA52A2A.
Definition: Color.h:107
static const Color kPapayaWhip
0xFFEFD5.
Definition: Color.h:582
static const Color kMediumSeaGreen
0x3CB371.
Definition: Color.h:477
static const Color kWheat
0xF5DEB3.
Definition: Color.h:727
static const Color kDarkSlateBlue
0x483D8B.
Definition: Color.h:222
static const Color kSeaGreen
0x2E8B57.
Definition: Color.h:647
static const Color kFloralWhite
0xFFFAF0.
Definition: Color.h:267
static const Color kCornsilk
0xFFF8DC.
Definition: Color.h:142
static const Color kSienna
0xA0522D.
Definition: Color.h:657
static const Color kBurlywood
0xDEB887.
Definition: Color.h:112
static const Color kPowderBlue
0xB0E0E6.
Definition: Color.h:607
static const Color kLimeGreen
0x32CD32.
Definition: Color.h:437
static const Color kChartreuse
0x7FFF00.
Definition: Color.h:122
static const Color kLawnGreen
0x7CFC00.
Definition: Color.h:357
static const Color kMediumTurquoise
0x48D1CC.
Definition: Color.h:492
static const Color kLightYellow
0xFFFFE0.
Definition: Color.h:427
static const Color kChocolate
0xD2691E.
Definition: Color.h:127
static const Color kWhite
0xFFFFFF.
Definition: Color.h:732
static const Color kDarkSeaGreen
0x8FBC8F.
Definition: Color.h:217
static const Color kMagenta
0xFF00FF.
Definition: Color.h:447
static const Color kDeepSkyBlue
0x00BFFF.
Definition: Color.h:247
static const Color kFirstRed
0xED1C24.
Definition: Color.h:43
static const Color kGoldenrod
0xDAA520.
Definition: Color.h:297
static const Color kBeige
0xF5F5DC.
Definition: Color.h:77
static const Color kSteelBlue
0x4682B4.
Definition: Color.h:692
static const Color kDarkKhaki
0xBDB76B.
Definition: Color.h:182
static const Color kNavajoWhite
0xFFDEAD.
Definition: Color.h:522
static const Color kPink
0xFFC0CB.
Definition: Color.h:597
static const Color kLinen
0xFAF0E6.
Definition: Color.h:442
static const Color kAquamarine
0x7FFFD4.
Definition: Color.h:67
constexpr Color(std::string_view hexString)
Constructs a Color from a hex string.
Definition: Color.h:782
static const Color kSilver
0xC0C0C0.
Definition: Color.h:662
static const Color kCyan
0x00FFFF.
Definition: Color.h:152
static const Color kSandyBrown
0xF4A460.
Definition: Color.h:642
static const Color kOlive
0x808000.
Definition: Color.h:537
static const Color kDarkOliveGreen
0x556B2F.
Definition: Color.h:192
static const Color kThistle
0xD8BFD8.
Definition: Color.h:707
static const Color kMaroon
0x800000.
Definition: Color.h:452
static const Color kAqua
0x00FFFF.
Definition: Color.h:62
static const Color kDarkGray
0xA9A9A9.
Definition: Color.h:172
static const Color kIndianRed
0xCD5C5C.
Definition: Color.h:327
static const Color kPeru
0xCD853F.
Definition: Color.h:592
static const Color kLightGoldenrodYellow
0xFAFAD2.
Definition: Color.h:382
static const Color kYellow
0xFFFF00.
Definition: Color.h:742
constexpr auto HexString() const
Return this color represented as a hex string.
Definition: Color.h:856
static const Color kCornflowerBlue
0x6495ED.
Definition: Color.h:137
static const Color kCadetBlue
0x5F9EA0.
Definition: Color.h:117
static const Color kLightGray
0xD3D3D3.
Definition: Color.h:387
static const Color kGainsboro
0xDCDCDC.
Definition: Color.h:282
static const Color kDarkBlue
0x00008B.
Definition: Color.h:157
static const Color kGhostWhite
0xF8F8FF.
Definition: Color.h:287
static const Color kOrange
0xFFA500.
Definition: Color.h:547
static const Color kWhiteSmoke
0xF5F5F5.
Definition: Color.h:737
static const Color kNavy
0x000080.
Definition: Color.h:527
static const Color kSkyBlue
0x87CEEB.
Definition: Color.h:667
static const Color kLightCyan
0xE0FFFF.
Definition: Color.h:377
static const Color kPaleTurquoise
0xAFEEEE.
Definition: Color.h:572
static const Color kSaddleBrown
0x8B4513.
Definition: Color.h:632
static const Color kSlateBlue
0x6A5ACD.
Definition: Color.h:672
static const Color kLime
0x00FF00.
Definition: Color.h:432
static const Color kLightPink
0xFFB6C1.
Definition: Color.h:397
basic_string_view< char > string_view
Definition: core.h:501
Definition: AprilTagPoseEstimator.h:15
constexpr return_t< T > ceil(const T x) noexcept
Compile-time ceil function.
Definition: ceil.hpp:130
static constexpr const unit_t< compound_unit< energy::joule, time::seconds > > h(6.626070040e-34)
Planck constant.
b
Definition: data.h:44
constexpr char hexdigit(unsigned X, bool LowerCase=false) noexcept
hexdigit - Return the hexadecimal character for the given number X (which should be less than 16).
Definition: StringExtras.h:37
constexpr bool isHexDigit(char C) noexcept
Checks if character C is a hexadecimal numeric character.
Definition: StringExtras.h:65
constexpr unsigned hexDigitValue(char C) noexcept
Interpret the given character C as a hexadecimal digit and return its value.
Definition: StringExtras.h:46
Fixed length string (array of character) for compile time use.
Definition: ct_string.h:29
auto format(wformat_string< T... > fmt, T &&... args) -> std::wstring
Definition: xchar.h:108