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