FastLED 3.9.15
Loading...
Searching...
No Matches
crgb.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <stdint.h>
7
8#include "chsv.h"
9#include "fl/namespace.h"
10#include "color.h"
11#include "lib8tion/types.h"
12#include "fl/force_inline.h"
13#include "fl/template_magic.h"
14
15
16namespace fl {
17class Str;
18}
19
21
22// Whether to allow HD_COLOR_MIXING
23#ifndef FASTLED_HD_COLOR_MIXING
24#ifdef __AVR__
25// Saves some memory on these constrained devices.
26#define FASTLED_HD_COLOR_MIXING 0
27#else
28#define FASTLED_HD_COLOR_MIXING 1
29#endif // __AVR__
30#endif // FASTLED_HD_COLOR_MIXING
31
32
33struct CRGB;
34
38
50void hsv2rgb_rainbow( const struct CHSV& hsv, struct CRGB& rgb);
51
52
54struct CRGB {
55 union {
56 struct {
57 union {
58 uint8_t r;
59 uint8_t red;
60 };
61 union {
62 uint8_t g;
63 uint8_t green;
64 };
65 union {
66 uint8_t b;
67 uint8_t blue;
68 };
69 };
70
75 uint8_t raw[3];
76 };
77
78 static CRGB blend(const CRGB& p1, const CRGB& p2, fract8 amountOfP2);
79 static CRGB blendAlphaMaxChannel(const CRGB& upper, const CRGB& lower);
80
85 {
86 return raw[x];
87 }
88
92 FASTLED_FORCE_INLINE const uint8_t& operator[] (uint8_t x) const
93 {
94 return raw[x];
95 }
96
100
105 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
106 : r(ir), g(ig), b(ib)
107 {
108 }
109
112 constexpr CRGB(uint32_t colorcode) noexcept
113 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
114 {
115 }
116
117 constexpr uint32_t as_uint32_t() const noexcept {
118 return uint32_t(0xff000000) |
119 (uint32_t{r} << 16) |
120 (uint32_t{g} << 8) |
121 uint32_t{b};
122 }
123
126 constexpr CRGB(LEDColorCorrection colorcode) noexcept
127 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
128 {
129 }
130
133 constexpr CRGB(ColorTemperature colorcode) noexcept
134 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
135 {
136 }
137
139 FASTLED_FORCE_INLINE CRGB(const CRGB& rhs) = default;
140
143 {
144 hsv2rgb_rainbow( rhs, *this);
145 }
146
148 FASTLED_FORCE_INLINE CRGB& operator= (const CRGB& rhs) = default;
149
152 FASTLED_FORCE_INLINE CRGB& operator= (const uint32_t colorcode)
153 {
154 r = (colorcode >> 16) & 0xFF;
155 g = (colorcode >> 8) & 0xFF;
156 b = (colorcode >> 0) & 0xFF;
157 return *this;
158 }
159
164 FASTLED_FORCE_INLINE CRGB& setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
165 {
166 r = nr;
167 g = ng;
168 b = nb;
169 return *this;
170 }
171
176 FASTLED_FORCE_INLINE CRGB& setHSV (uint8_t hue, uint8_t sat, uint8_t val)
177 {
178 hsv2rgb_rainbow( CHSV(hue, sat, val), *this);
179 return *this;
180 }
181
186 {
187 hsv2rgb_rainbow( CHSV(hue, 255, 255), *this);
188 return *this;
189 }
190
193 {
194 hsv2rgb_rainbow( rhs, *this);
195 return *this;
196 }
197
201 {
202 r = (colorcode >> 16) & 0xFF;
203 g = (colorcode >> 8) & 0xFF;
204 b = (colorcode >> 0) & 0xFF;
205 return *this;
206 }
207
208
211
217
220
226
229
232
235
238
241 {
242 r /= d;
243 g /= d;
244 b /= d;
245 return *this;
246 }
247
250 {
251 r >>= d;
252 g >>= d;
253 b >>= d;
254 return *this;
255 }
256
260
267 FASTLED_FORCE_INLINE CRGB& nscale8_video (uint8_t scaledown);
268
271 FASTLED_FORCE_INLINE CRGB& operator%= (uint8_t scaledown);
272
275 FASTLED_FORCE_INLINE CRGB& fadeLightBy (uint8_t fadefactor );
276
281 CRGB& nscale8 (uint8_t scaledown );
282
287 FASTLED_FORCE_INLINE CRGB& nscale8 (const CRGB & scaledown );
288
289 constexpr CRGB nscale8_constexpr (const CRGB scaledown ) const;
290
291
293 FASTLED_FORCE_INLINE CRGB scale8 (uint8_t scaledown ) const;
294
296 FASTLED_FORCE_INLINE CRGB scale8 (const CRGB & scaledown ) const;
297
300 FASTLED_FORCE_INLINE CRGB& fadeToBlackBy (uint8_t fadefactor );
301
304 {
305 if( rhs.r > r) r = rhs.r;
306 if( rhs.g > g) g = rhs.g;
307 if( rhs.b > b) b = rhs.b;
308 return *this;
309 }
310
313 {
314 if( d > r) r = d;
315 if( d > g) g = d;
316 if( d > b) b = d;
317 return *this;
318 }
319
322 {
323 if( rhs.r < r) r = rhs.r;
324 if( rhs.g < g) g = rhs.g;
325 if( rhs.b < b) b = rhs.b;
326 return *this;
327 }
328
331 {
332 if( d < r) r = d;
333 if( d < g) g = d;
334 if( d < b) b = d;
335 return *this;
336 }
337
339 constexpr explicit operator bool() const
340 {
341 return r || g || b;
342 }
343
345 constexpr explicit operator uint32_t() const
346 {
347 return uint32_t(0xff000000) |
348 (uint32_t{r} << 16) |
349 (uint32_t{g} << 8) |
350 uint32_t{b};
351 }
352
354 constexpr CRGB operator-() const
355 {
356 return CRGB(255 - r, 255 - g, 255 - b);
357 }
358
359#if (defined SmartMatrix_h || defined SmartMatrix3_h)
362 operator rgb24() const {
363 rgb24 ret;
364 ret.red = r;
365 ret.green = g;
366 ret.blue = b;
367 return ret;
368 }
369#endif
370
371 fl::Str toString() const;
372
375 uint8_t getLuma() const;
376
377
378
381
387 FASTLED_FORCE_INLINE void maximizeBrightness( uint8_t limit = 255 ) {
388 uint8_t max = red;
389 if( green > max) max = green;
390 if( blue > max) max = blue;
391
392 // stop div/0 when color is black
393 if(max > 0) {
394 uint16_t factor = ((uint16_t)(limit) * 256) / max;
395 red = (red * factor) / 256;
396 green = (green * factor) / 256;
397 blue = (blue * factor) / 256;
398 }
399 }
400
406 static CRGB computeAdjustment(uint8_t scale, const CRGB & colorCorrection, const CRGB & colorTemperature);
407
409 FASTLED_FORCE_INLINE CRGB lerp8( const CRGB& other, fract8 frac) const;
410
412 FASTLED_FORCE_INLINE CRGB lerp16( const CRGB& other, fract16 frac) const;
415 {
416 uint8_t sum = r + g + b;
417 return (sum & 0x01);
418 }
419
442 FASTLED_FORCE_INLINE void setParity( uint8_t parity)
443 {
444 uint8_t curparity = getParity();
445
446 if( parity == curparity) return;
447
448 if( parity ) {
449 // going 'up'
450 if( (b > 0) && (b < 255)) {
451 if( r == g && g == b) {
452 ++r;
453 ++g;
454 }
455 ++b;
456 } else if( (r > 0) && (r < 255)) {
457 ++r;
458 } else if( (g > 0) && (g < 255)) {
459 ++g;
460 } else {
461 if( r == g && g == b) {
462 r ^= 0x01;
463 g ^= 0x01;
464 }
465 b ^= 0x01;
466 }
467 } else {
468 // going 'down'
469 if( b > 1) {
470 if( r == g && g == b) {
471 --r;
472 --g;
473 }
474 --b;
475 } else if( g > 1) {
476 --g;
477 } else if( r > 1) {
478 --r;
479 } else {
480 if( r == g && g == b) {
481 r ^= 0x01;
482 g ^= 0x01;
483 }
484 b ^= 0x01;
485 }
486 }
487 }
488
490 typedef enum {
491 AliceBlue=0xF0F8FF,
492 Amethyst=0x9966CC,
493 AntiqueWhite=0xFAEBD7,
494 Aqua=0x00FFFF,
495 Aquamarine=0x7FFFD4,
496 Azure=0xF0FFFF,
497 Beige=0xF5F5DC,
498 Bisque=0xFFE4C4,
499 Black=0x000000,
500 BlanchedAlmond=0xFFEBCD,
501 Blue=0x0000FF,
502 BlueViolet=0x8A2BE2,
503 Brown=0xA52A2A,
504 BurlyWood=0xDEB887,
505 CadetBlue=0x5F9EA0,
506 Chartreuse=0x7FFF00,
507 Chocolate=0xD2691E,
508 Coral=0xFF7F50,
509 CornflowerBlue=0x6495ED,
510 Cornsilk=0xFFF8DC,
511 Crimson=0xDC143C,
512 Cyan=0x00FFFF,
513 DarkBlue=0x00008B,
514 DarkCyan=0x008B8B,
515 DarkGoldenrod=0xB8860B,
516 DarkGray=0xA9A9A9,
517 DarkGrey=0xA9A9A9,
518 DarkGreen=0x006400,
519 DarkKhaki=0xBDB76B,
520 DarkMagenta=0x8B008B,
521 DarkOliveGreen=0x556B2F,
522 DarkOrange=0xFF8C00,
523 DarkOrchid=0x9932CC,
524 DarkRed=0x8B0000,
525 DarkSalmon=0xE9967A,
526 DarkSeaGreen=0x8FBC8F,
527 DarkSlateBlue=0x483D8B,
528 DarkSlateGray=0x2F4F4F,
529 DarkSlateGrey=0x2F4F4F,
530 DarkTurquoise=0x00CED1,
531 DarkViolet=0x9400D3,
532 DeepPink=0xFF1493,
533 DeepSkyBlue=0x00BFFF,
534 DimGray=0x696969,
535 DimGrey=0x696969,
536 DodgerBlue=0x1E90FF,
537 FireBrick=0xB22222,
538 FloralWhite=0xFFFAF0,
539 ForestGreen=0x228B22,
540 Fuchsia=0xFF00FF,
541 Gainsboro=0xDCDCDC,
542 GhostWhite=0xF8F8FF,
543 Gold=0xFFD700,
544 Goldenrod=0xDAA520,
545 Gray=0x808080,
546 Grey=0x808080,
547 Green=0x008000,
548 GreenYellow=0xADFF2F,
549 Honeydew=0xF0FFF0,
550 HotPink=0xFF69B4,
551 IndianRed=0xCD5C5C,
552 Indigo=0x4B0082,
553 Ivory=0xFFFFF0,
554 Khaki=0xF0E68C,
555 Lavender=0xE6E6FA,
556 LavenderBlush=0xFFF0F5,
557 LawnGreen=0x7CFC00,
558 LemonChiffon=0xFFFACD,
559 LightBlue=0xADD8E6,
560 LightCoral=0xF08080,
561 LightCyan=0xE0FFFF,
563 LightGreen=0x90EE90,
564 LightGrey=0xD3D3D3,
565 LightPink=0xFFB6C1,
566 LightSalmon=0xFFA07A,
567 LightSeaGreen=0x20B2AA,
568 LightSkyBlue=0x87CEFA,
569 LightSlateGray=0x778899,
570 LightSlateGrey=0x778899,
571 LightSteelBlue=0xB0C4DE,
572 LightYellow=0xFFFFE0,
573 Lime=0x00FF00,
574 LimeGreen=0x32CD32,
575 Linen=0xFAF0E6,
576 Magenta=0xFF00FF,
577 Maroon=0x800000,
579 MediumBlue=0x0000CD,
580 MediumOrchid=0xBA55D3,
581 MediumPurple=0x9370DB,
582 MediumSeaGreen=0x3CB371,
587 MidnightBlue=0x191970,
588 MintCream=0xF5FFFA,
589 MistyRose=0xFFE4E1,
590 Moccasin=0xFFE4B5,
591 NavajoWhite=0xFFDEAD,
592 Navy=0x000080,
593 OldLace=0xFDF5E6,
594 Olive=0x808000,
595 OliveDrab=0x6B8E23,
596 Orange=0xFFA500,
597 OrangeRed=0xFF4500,
598 Orchid=0xDA70D6,
599 PaleGoldenrod=0xEEE8AA,
600 PaleGreen=0x98FB98,
601 PaleTurquoise=0xAFEEEE,
602 PaleVioletRed=0xDB7093,
603 PapayaWhip=0xFFEFD5,
604 PeachPuff=0xFFDAB9,
605 Peru=0xCD853F,
606 Pink=0xFFC0CB,
607 Plaid=0xCC5533,
608 Plum=0xDDA0DD,
609 PowderBlue=0xB0E0E6,
610 Purple=0x800080,
611 Red=0xFF0000,
612 RosyBrown=0xBC8F8F,
613 RoyalBlue=0x4169E1,
614 SaddleBrown=0x8B4513,
615 Salmon=0xFA8072,
616 SandyBrown=0xF4A460,
617 SeaGreen=0x2E8B57,
618 Seashell=0xFFF5EE,
619 Sienna=0xA0522D,
620 Silver=0xC0C0C0,
621 SkyBlue=0x87CEEB,
622 SlateBlue=0x6A5ACD,
623 SlateGray=0x708090,
624 SlateGrey=0x708090,
625 Snow=0xFFFAFA,
626 SpringGreen=0x00FF7F,
627 SteelBlue=0x4682B4,
628 Tan=0xD2B48C,
629 Teal=0x008080,
630 Thistle=0xD8BFD8,
631 Tomato=0xFF6347,
632 Turquoise=0x40E0D0,
633 Violet=0xEE82EE,
634 Wheat=0xF5DEB3,
635 White=0xFFFFFF,
636 WhiteSmoke=0xF5F5F5,
637 Yellow=0xFFFF00,
638 YellowGreen=0x9ACD32,
639
640 // LED RGB color that roughly approximates
641 // the color of incandescent fairy lights,
642 // assuming that you're using FastLED
643 // color correction on your LEDs (recommended).
644 FairyLight=0xFFE42D,
645
646 // If you are using no color correction, use this
648
650};
651
652
654FASTLED_FORCE_INLINE bool operator== (const CRGB& lhs, const CRGB& rhs)
655{
656 return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
657}
658
660FASTLED_FORCE_INLINE bool operator!= (const CRGB& lhs, const CRGB& rhs)
661{
662 return !(lhs == rhs);
663}
664
666FASTLED_FORCE_INLINE bool operator== (const CHSV& lhs, const CHSV& rhs)
667{
668 return (lhs.h == rhs.h) && (lhs.s == rhs.s) && (lhs.v == rhs.v);
669}
670
672FASTLED_FORCE_INLINE bool operator!= (const CHSV& lhs, const CHSV& rhs)
673{
674 return !(lhs == rhs);
675}
676
678FASTLED_FORCE_INLINE bool operator< (const CRGB& lhs, const CRGB& rhs)
679{
680 uint16_t sl, sr;
681 sl = lhs.r + lhs.g + lhs.b;
682 sr = rhs.r + rhs.g + rhs.b;
683 return sl < sr;
684}
685
687FASTLED_FORCE_INLINE bool operator> (const CRGB& lhs, const CRGB& rhs)
688{
689 uint16_t sl, sr;
690 sl = lhs.r + lhs.g + lhs.b;
691 sr = rhs.r + rhs.g + rhs.b;
692 return sl > sr;
693}
694
696FASTLED_FORCE_INLINE bool operator>= (const CRGB& lhs, const CRGB& rhs)
697{
698 uint16_t sl, sr;
699 sl = lhs.r + lhs.g + lhs.b;
700 sr = rhs.r + rhs.g + rhs.b;
701 return sl >= sr;
702}
703
705FASTLED_FORCE_INLINE bool operator<= (const CRGB& lhs, const CRGB& rhs)
706{
707 uint16_t sl, sr;
708 sl = lhs.r + lhs.g + lhs.b;
709 sr = rhs.r + rhs.g + rhs.b;
710 return sl <= sr;
711}
712
713
714
717{
718 return CRGB( p1.r/d, p1.g/d, p1.b/d);
719}
720
721
724{
725 return CRGB( p1.r < p2.r ? p1.r : p2.r,
726 p1.g < p2.g ? p1.g : p2.g,
727 p1.b < p2.b ? p1.b : p2.b);
728}
729
732{
733 return CRGB( p1.r > p2.r ? p1.r : p2.r,
734 p1.g > p2.g ? p1.g : p2.g,
735 p1.b > p2.b ? p1.b : p2.b);
736}
737
739FASTLED_FORCE_INLINE CRGB operator+( const CRGB& p1, const CRGB& p2);
740
742FASTLED_FORCE_INLINE CRGB operator-( const CRGB& p1, const CRGB& p2);
743
745FASTLED_FORCE_INLINE CRGB operator*( const CRGB& p1, uint8_t d);
746
748FASTLED_FORCE_INLINE CRGB operator%( const CRGB& p1, uint8_t d);
749
751
752
754
755
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
UISlider scale("Scale", 4,.1, 4,.1)
Defines the hue, saturation, and value (HSV) pixel struct.
Definition str.h:368
#define FASTLED_FORCE_INLINE
Definition force_inline.h:7
ColorTemperature
Color temperature values.
Definition color.h:46
LEDColorCorrection
Color correction starting points.
Definition color.h:15
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:36
uint16_t fract16
ANSI: unsigned _Fract.
Definition types.h:46
FASTLED_FORCE_INLINE bool operator!=(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects do not have the same color data.
Definition crgb.h:660
FASTLED_FORCE_INLINE bool operator<=(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is less than or equal to another.
Definition crgb.h:705
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:654
FASTLED_FORCE_INLINE CRGB operator/(const CRGB &p1, uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:716
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
Definition crgb.hpp:224
FASTLED_FORCE_INLINE CRGB operator-(const CRGB &p1, const CRGB &p2)
Subtract one CRGB from another, saturating at 0x00 for each channel.
Definition crgb.hpp:208
FASTLED_FORCE_INLINE bool operator<(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is less than another.
Definition crgb.h:678
FASTLED_FORCE_INLINE CRGB operator|(const CRGB &p1, const CRGB &p2)
Combine two CRGB objects, taking the largest value of each channel.
Definition crgb.h:731
FASTLED_FORCE_INLINE CRGB operator&(const CRGB &p1, const CRGB &p2)
Combine two CRGB objects, taking the smallest value of each channel.
Definition crgb.h:723
FASTLED_FORCE_INLINE bool operator>(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is greater than another.
Definition crgb.h:687
void hsv2rgb_rainbow(const struct CHSV &hsv, struct CRGB &rgb)
Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.
FASTLED_FORCE_INLINE bool operator>=(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is greater than or equal to another.
Definition crgb.h:696
FASTLED_FORCE_INLINE CRGB operator*(const CRGB &p1, uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
Definition crgb.hpp:216
FASTLED_FORCE_INLINE CRGB operator+(const CRGB &p1, const CRGB &p2)
Add one CRGB to another, saturating at 0xFF for each channel.
Definition crgb.hpp:200
Defines fractional types used for lib8tion functions.
#define FASTLED_NAMESPACE_END
Definition namespace.h:22
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Contains definitions for color correction and temperature.
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16
FASTLED_FORCE_INLINE CRGB & nscale8_video(uint8_t scaledown)
Scale down a RGB to N/256ths of it's current brightness using "video" dimming rules.
Definition crgb.hpp:78
FASTLED_FORCE_INLINE CRGB()=default
Default constructor.
uint8_t getLuma() const
Get the "luma" of a CRGB object.
Definition crgb.hpp:152
FASTLED_FORCE_INLINE uint8_t getParity()
Returns 0 or 1, depending on the lowest bit of the sum of the color components.
Definition crgb.h:414
FASTLED_FORCE_INLINE CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:240
FASTLED_FORCE_INLINE CRGB & fadeLightBy(uint8_t fadefactor)
fadeLightBy is a synonym for nscale8_video(), as a fade instead of a scale
Definition crgb.hpp:90
constexpr CRGB(ColorTemperature colorcode) noexcept
Allow construction from a ColorTemperature enum.
Definition crgb.h:133
FASTLED_FORCE_INLINE CRGB(const CRGB &rhs)=default
Allow copy construction.
FASTLED_FORCE_INLINE CRGB & operator++()
Add a constant of '1' from each channel, saturating at 0xFF.
Definition crgb.hpp:48
constexpr uint32_t as_uint32_t() const noexcept
Definition crgb.h:117
constexpr CRGB(uint32_t colorcode) noexcept
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
Definition crgb.h:112
FASTLED_FORCE_INLINE CRGB lerp16(const CRGB &other, fract16 frac) const
Return a new CRGB object after performing a linear interpolation between this object and the passed i...
Definition crgb.hpp:187
FASTLED_FORCE_INLINE CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
Definition crgb.hpp:39
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:72
FASTLED_FORCE_INLINE CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
Definition crgb.h:164
FASTLED_FORCE_INLINE CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
Definition crgb.h:200
static CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Definition crgb.cpp:50
FASTLED_FORCE_INLINE CRGB & operator=(const CRGB &rhs)=default
Allow assignment from one RGB struct to another.
FASTLED_FORCE_INLINE void setParity(uint8_t parity)
Adjusts the color in the smallest way possible so that the parity of the coloris now the desired valu...
Definition crgb.h:442
static CRGB computeAdjustment(uint8_t scale, const CRGB &colorCorrection, const CRGB &colorTemperature)
Calculates the combined color adjustment to the LEDs at a given scale, color correction,...
Definition crgb.cpp:25
FASTLED_FORCE_INLINE CRGB(const CHSV &rhs)
Allow construction from a CHSV color.
Definition crgb.h:142
FASTLED_FORCE_INLINE CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
Definition crgb.h:176
FASTLED_FORCE_INLINE CRGB & operator--()
Subtract a constant of '1' from each channel, saturating at 0x00.
Definition crgb.hpp:97
FASTLED_FORCE_INLINE CRGB lerp8(const CRGB &other, fract8 frac) const
Return a new CRGB object after performing a linear interpolation between this object and the passed i...
Definition crgb.hpp:176
FASTLED_FORCE_INLINE CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
Definition crgb.h:249
constexpr CRGB operator-() const
Invert each channel.
Definition crgb.h:354
FASTLED_FORCE_INLINE uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
Definition crgb.h:84
FASTLED_FORCE_INLINE CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
Definition crgb.h:321
FASTLED_FORCE_INLINE uint8_t getAverageLight() const
Get the average of the R, G, and B values.
Definition crgb.hpp:163
FASTLED_FORCE_INLINE CRGB & addToRGB(uint8_t d)
Add a constant to each channel, saturating at 0xFF.
Definition crgb.hpp:31
FASTLED_FORCE_INLINE CRGB & subtractFromRGB(uint8_t d)
Subtract a constant from each channel, saturating at 0x00.
Definition crgb.hpp:62
constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
Allow construction from red, green, and blue.
Definition crgb.h:105
FASTLED_FORCE_INLINE CRGB scale8(uint8_t scaledown) const
Return a CRGB object that is a scaled down version of this object.
Definition crgb.hpp:130
fl::Str toString() const
Definition crgb.cpp:13
FASTLED_FORCE_INLINE CRGB & operator*=(uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
Definition crgb.hpp:70
static CRGB blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower)
Definition crgb.cpp:58
FASTLED_FORCE_INLINE CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
Definition crgb.h:185
FASTLED_FORCE_INLINE CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
Definition crgb.hpp:84
FASTLED_FORCE_INLINE CRGB & operator+=(const CRGB &rhs)
Add one CRGB to another, saturating at 0xFF for each channel.
Definition crgb.hpp:23
FASTLED_FORCE_INLINE void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
Definition crgb.h:387
constexpr CRGB(LEDColorCorrection colorcode) noexcept
Allow construction from a LEDColorCorrection enum.
Definition crgb.h:126
HTMLColorCode
Predefined RGB colors.
Definition crgb.h:490
@ DarkGray
<div style='background:#A9A9A9;width:4em;height:4em;'></div>
Definition crgb.h:516
@ Sienna
<div style='background:#A0522D;width:4em;height:4em;'></div>
Definition crgb.h:619
@ Plum
<div style='background:#DDA0DD;width:4em;height:4em;'></div>
Definition crgb.h:608
@ GhostWhite
<div style='background:#F8F8FF;width:4em;height:4em;'></div>
Definition crgb.h:542
@ Tan
<div style='background:#D2B48C;width:4em;height:4em;'></div>
Definition crgb.h:628
@ Gold
<div style='background:#FFD700;width:4em;height:4em;'></div>
Definition crgb.h:543
@ DarkRed
<div style='background:#8B0000;width:4em;height:4em;'></div>
Definition crgb.h:524
@ DarkSlateGray
<div style='background:#2F4F4F;width:4em;height:4em;'></div>
Definition crgb.h:528
@ OldLace
<div style='background:#FDF5E6;width:4em;height:4em;'></div>
Definition crgb.h:593
@ Aquamarine
<div style='background:#7FFFD4;width:4em;height:4em;'></div>
Definition crgb.h:495
@ Violet
<div style='background:#EE82EE;width:4em;height:4em;'></div>
Definition crgb.h:633
@ Salmon
<div style='background:#FA8072;width:4em;height:4em;'></div>
Definition crgb.h:615
@ Thistle
<div style='background:#D8BFD8;width:4em;height:4em;'></div>
Definition crgb.h:630
@ Cornsilk
<div style='background:#FFF8DC;width:4em;height:4em;'></div>
Definition crgb.h:510
@ MediumVioletRed
<div style='background:#C71585;width:4em;height:4em;'></div>
Definition crgb.h:586
@ Coral
<div style='background:#FF7F50;width:4em;height:4em;'></div>
Definition crgb.h:508
@ LightPink
<div style='background:#FFB6C1;width:4em;height:4em;'></div>
Definition crgb.h:565
@ DarkGrey
<div style='background:#A9A9A9;width:4em;height:4em;'></div>
Definition crgb.h:517
@ SlateGrey
<div style='background:#708090;width:4em;height:4em;'></div>
Definition crgb.h:624
@ NavajoWhite
<div style='background:#FFDEAD;width:4em;height:4em;'></div>
Definition crgb.h:591
@ PaleVioletRed
<div style='background:#DB7093;width:4em;height:4em;'></div>
Definition crgb.h:602
@ HotPink
<div style='background:#FF69B4;width:4em;height:4em;'></div>
Definition crgb.h:550
@ BlanchedAlmond
<div style='background:#FFEBCD;width:4em;height:4em;'></div>
Definition crgb.h:500
@ RosyBrown
<div style='background:#BC8F8F;width:4em;height:4em;'></div>
Definition crgb.h:612
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:635
@ Moccasin
<div style='background:#FFE4B5;width:4em;height:4em;'></div>
Definition crgb.h:590
@ LightYellow
<div style='background:#FFFFE0;width:4em;height:4em;'></div>
Definition crgb.h:572
@ Bisque
<div style='background:#FFE4C4;width:4em;height:4em;'></div>
Definition crgb.h:498
@ DeepPink
<div style='background:#FF1493;width:4em;height:4em;'></div>
Definition crgb.h:532
@ Wheat
<div style='background:#F5DEB3;width:4em;height:4em;'></div>
Definition crgb.h:634
@ MediumOrchid
<div style='background:#BA55D3;width:4em;height:4em;'></div>
Definition crgb.h:580
@ Goldenrod
<div style='background:#DAA520;width:4em;height:4em;'></div>
Definition crgb.h:544
@ Orange
<div style='background:#FFA500;width:4em;height:4em;'></div>
Definition crgb.h:596
@ MediumSpringGreen
<div style='background:#00FA9A;width:4em;height:4em;'></div>
Definition crgb.h:584
@ Seashell
<div style='background:#FFF5EE;width:4em;height:4em;'></div>
Definition crgb.h:618
@ DarkViolet
<div style='background:#9400D3;width:4em;height:4em;'></div>
Definition crgb.h:531
@ Ivory
<div style='background:#FFFFF0;width:4em;height:4em;'></div>
Definition crgb.h:553
@ Teal
<div style='background:#008080;width:4em;height:4em;'></div>
Definition crgb.h:629
@ Gray
<div style='background:#808080;width:4em;height:4em;'></div>
Definition crgb.h:545
@ MistyRose
<div style='background:#FFE4E1;width:4em;height:4em;'></div>
Definition crgb.h:589
@ SlateBlue
<div style='background:#6A5ACD;width:4em;height:4em;'></div>
Definition crgb.h:622
@ Silver
<div style='background:#C0C0C0;width:4em;height:4em;'></div>
Definition crgb.h:620
@ Purple
<div style='background:#800080;width:4em;height:4em;'></div>
Definition crgb.h:610
@ DarkKhaki
<div style='background:#BDB76B;width:4em;height:4em;'></div>
Definition crgb.h:519
@ SaddleBrown
<div style='background:#8B4513;width:4em;height:4em;'></div>
Definition crgb.h:614
@ LemonChiffon
<div style='background:#FFFACD;width:4em;height:4em;'></div>
Definition crgb.h:558
@ Magenta
<div style='background:#FF00FF;width:4em;height:4em;'></div>
Definition crgb.h:576
@ Beige
<div style='background:#F5F5DC;width:4em;height:4em;'></div>
Definition crgb.h:497
@ Crimson
<div style='background:#DC143C;width:4em;height:4em;'></div>
Definition crgb.h:511
@ MediumAquamarine
<div style='background:#66CDAA;width:4em;height:4em;'></div>
Definition crgb.h:578
@ LawnGreen
<div style='background:#7CFC00;width:4em;height:4em;'></div>
Definition crgb.h:557
@ DodgerBlue
<div style='background:#1E90FF;width:4em;height:4em;'></div>
Definition crgb.h:536
@ Tomato
<div style='background:#FF6347;width:4em;height:4em;'></div>
Definition crgb.h:631
@ Fuchsia
<div style='background:#FF00FF;width:4em;height:4em;'></div>
Definition crgb.h:540
@ Aqua
<div style='background:#00FFFF;width:4em;height:4em;'></div>
Definition crgb.h:494
@ Brown
<div style='background:#A52A2A;width:4em;height:4em;'></div>
Definition crgb.h:503
@ Pink
<div style='background:#FFC0CB;width:4em;height:4em;'></div>
Definition crgb.h:606
@ Lavender
<div style='background:#E6E6FA;width:4em;height:4em;'></div>
Definition crgb.h:555
@ YellowGreen
<div style='background:#9ACD32;width:4em;height:4em;'></div>
Definition crgb.h:638
@ DeepSkyBlue
<div style='background:#00BFFF;width:4em;height:4em;'></div>
Definition crgb.h:533
@ Turquoise
<div style='background:#40E0D0;width:4em;height:4em;'></div>
Definition crgb.h:632
@ SandyBrown
<div style='background:#F4A460;width:4em;height:4em;'></div>
Definition crgb.h:616
@ MediumSlateBlue
<div style='background:#7B68EE;width:4em;height:4em;'></div>
Definition crgb.h:583
@ PeachPuff
<div style='background:#FFDAB9;width:4em;height:4em;'></div>
Definition crgb.h:604
@ Orchid
<div style='background:#DA70D6;width:4em;height:4em;'></div>
Definition crgb.h:598
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
Definition crgb.h:547
@ SteelBlue
<div style='background:#4682B4;width:4em;height:4em;'></div>
Definition crgb.h:627
@ CornflowerBlue
<div style='background:#6495ED;width:4em;height:4em;'></div>
Definition crgb.h:509
@ DarkSalmon
<div style='background:#E9967A;width:4em;height:4em;'></div>
Definition crgb.h:525
@ SkyBlue
<div style='background:#87CEEB;width:4em;height:4em;'></div>
Definition crgb.h:621
@ LightSalmon
<div style='background:#FFA07A;width:4em;height:4em;'></div>
Definition crgb.h:566
@ RoyalBlue
<div style='background:#4169E1;width:4em;height:4em;'></div>
Definition crgb.h:613
@ DarkSlateGrey
<div style='background:#2F4F4F;width:4em;height:4em;'></div>
Definition crgb.h:529
@ Navy
<div style='background:#000080;width:4em;height:4em;'></div>
Definition crgb.h:592
@ Lime
<div style='background:#00FF00;width:4em;height:4em;'></div>
Definition crgb.h:573
@ LightCoral
<div style='background:#F08080;width:4em;height:4em;'></div>
Definition crgb.h:560
@ PaleTurquoise
<div style='background:#AFEEEE;width:4em;height:4em;'></div>
Definition crgb.h:601
@ BurlyWood
<div style='background:#DEB887;width:4em;height:4em;'></div>
Definition crgb.h:504
@ DarkTurquoise
<div style='background:#00CED1;width:4em;height:4em;'></div>
Definition crgb.h:530
@ DarkMagenta
<div style='background:#8B008B;width:4em;height:4em;'></div>
Definition crgb.h:520
@ LightSeaGreen
<div style='background:#20B2AA;width:4em;height:4em;'></div>
Definition crgb.h:567
@ MidnightBlue
<div style='background:#191970;width:4em;height:4em;'></div>
Definition crgb.h:587
@ LightSlateGray
<div style='background:#778899;width:4em;height:4em;'></div>
Definition crgb.h:569
@ Chocolate
<div style='background:#D2691E;width:4em;height:4em;'></div>
Definition crgb.h:507
@ Linen
<div style='background:#FAF0E6;width:4em;height:4em;'></div>
Definition crgb.h:575
@ SeaGreen
<div style='background:#2E8B57;width:4em;height:4em;'></div>
Definition crgb.h:617
@ Cyan
<div style='background:#00FFFF;width:4em;height:4em;'></div>
Definition crgb.h:512
@ AntiqueWhite
<div style='background:#FAEBD7;width:4em;height:4em;'></div>
Definition crgb.h:493
@ LimeGreen
<div style='background:#32CD32;width:4em;height:4em;'></div>
Definition crgb.h:574
@ MediumTurquoise
<div style='background:#48D1CC;width:4em;height:4em;'></div>
Definition crgb.h:585
@ LightGreen
<div style='background:#90EE90;width:4em;height:4em;'></div>
Definition crgb.h:563
@ MediumSeaGreen
<div style='background:#3CB371;width:4em;height:4em;'></div>
Definition crgb.h:582
@ PaleGreen
<div style='background:#98FB98;width:4em;height:4em;'></div>
Definition crgb.h:600
@ FireBrick
<div style='background:#B22222;width:4em;height:4em;'></div>
Definition crgb.h:537
@ Amethyst
<div style='background:#9966CC;width:4em;height:4em;'></div>
Definition crgb.h:492
@ LightSteelBlue
<div style='background:#B0C4DE;width:4em;height:4em;'></div>
Definition crgb.h:571
@ LightGrey
<div style='background:#D3D3D3;width:4em;height:4em;'></div>
Definition crgb.h:564
@ BlueViolet
<div style='background:#8A2BE2;width:4em;height:4em;'></div>
Definition crgb.h:502
@ Indigo
<div style='background:#4B0082;width:4em;height:4em;'></div>
Definition crgb.h:552
@ LightCyan
<div style='background:#E0FFFF;width:4em;height:4em;'></div>
Definition crgb.h:561
@ Olive
<div style='background:#808000;width:4em;height:4em;'></div>
Definition crgb.h:594
@ PapayaWhip
<div style='background:#FFEFD5;width:4em;height:4em;'></div>
Definition crgb.h:603
@ Azure
<div style='background:#F0FFFF;width:4em;height:4em;'></div>
Definition crgb.h:496
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:501
@ DarkOrchid
<div style='background:#9932CC;width:4em;height:4em;'></div>
Definition crgb.h:523
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:611
@ PowderBlue
<div style='background:#B0E0E6;width:4em;height:4em;'></div>
Definition crgb.h:609
@ IndianRed
<div style='background:#CD5C5C;width:4em;height:4em;'></div>
Definition crgb.h:551
@ FairyLight
<div style='background:#FFE42D;width:4em;height:4em;'></div>
Definition crgb.h:644
@ DarkGoldenrod
<div style='background:#B8860B;width:4em;height:4em;'></div>
Definition crgb.h:515
@ LightSkyBlue
<div style='background:#87CEFA;width:4em;height:4em;'></div>
Definition crgb.h:568
@ DarkSlateBlue
<div style='background:#483D8B;width:4em;height:4em;'></div>
Definition crgb.h:527
@ MediumBlue
<div style='background:#0000CD;width:4em;height:4em;'></div>
Definition crgb.h:579
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:499
@ LavenderBlush
<div style='background:#FFF0F5;width:4em;height:4em;'></div>
Definition crgb.h:556
@ DarkOrange
<div style='background:#FF8C00;width:4em;height:4em;'></div>
Definition crgb.h:522
@ CadetBlue
<div style='background:#5F9EA0;width:4em;height:4em;'></div>
Definition crgb.h:505
@ SlateGray
<div style='background:#708090;width:4em;height:4em;'></div>
Definition crgb.h:623
@ OliveDrab
<div style='background:#6B8E23;width:4em;height:4em;'></div>
Definition crgb.h:595
@ Plaid
<div style='background:#CC5533;width:4em;height:4em;'></div>
Definition crgb.h:607
@ SpringGreen
<div style='background:#00FF7F;width:4em;height:4em;'></div>
Definition crgb.h:626
@ Honeydew
<div style='background:#F0FFF0;width:4em;height:4em;'></div>
Definition crgb.h:549
@ Gainsboro
<div style='background:#DCDCDC;width:4em;height:4em;'></div>
Definition crgb.h:541
@ MediumPurple
<div style='background:#9370DB;width:4em;height:4em;'></div>
Definition crgb.h:581
@ Yellow
<div style='background:#FFFF00;width:4em;height:4em;'></div>
Definition crgb.h:637
@ DimGrey
<div style='background:#696969;width:4em;height:4em;'></div>
Definition crgb.h:535
@ FairyLightNCC
<div style='background:#FFE42D;width:4em;height:4em;'></div>
Definition crgb.h:647
@ DarkOliveGreen
<div style='background:#556B2F;width:4em;height:4em;'></div>
Definition crgb.h:521
@ LightGoldenrodYellow
<div style='background:#FAFAD2;width:4em;height:4em;'></div>
Definition crgb.h:562
@ LightSlateGrey
<div style='background:#778899;width:4em;height:4em;'></div>
Definition crgb.h:570
@ Peru
<div style='background:#CD853F;width:4em;height:4em;'></div>
Definition crgb.h:605
@ AliceBlue
<div style='background:#F0F8FF;width:4em;height:4em;'></div>
Definition crgb.h:491
@ PaleGoldenrod
<div style='background:#EEE8AA;width:4em;height:4em;'></div>
Definition crgb.h:599
@ DarkSeaGreen
<div style='background:#8FBC8F;width:4em;height:4em;'></div>
Definition crgb.h:526
@ LightBlue
<div style='background:#ADD8E6;width:4em;height:4em;'></div>
Definition crgb.h:559
@ FloralWhite
<div style='background:#FFFAF0;width:4em;height:4em;'></div>
Definition crgb.h:538
@ Chartreuse
<div style='background:#7FFF00;width:4em;height:4em;'></div>
Definition crgb.h:506
@ DimGray
<div style='background:#696969;width:4em;height:4em;'></div>
Definition crgb.h:534
@ OrangeRed
<div style='background:#FF4500;width:4em;height:4em;'></div>
Definition crgb.h:597
@ ForestGreen
<div style='background:#228B22;width:4em;height:4em;'></div>
Definition crgb.h:539
@ Khaki
<div style='background:#F0E68C;width:4em;height:4em;'></div>
Definition crgb.h:554
@ MintCream
<div style='background:#F5FFFA;width:4em;height:4em;'></div>
Definition crgb.h:588
@ DarkCyan
<div style='background:#008B8B;width:4em;height:4em;'></div>
Definition crgb.h:514
@ Snow
<div style='background:#FFFAFA;width:4em;height:4em;'></div>
Definition crgb.h:625
@ DarkGreen
<div style='background:#006400;width:4em;height:4em;'></div>
Definition crgb.h:518
@ GreenYellow
<div style='background:#ADFF2F;width:4em;height:4em;'></div>
Definition crgb.h:548
@ WhiteSmoke
<div style='background:#F5F5F5;width:4em;height:4em;'></div>
Definition crgb.h:636
@ DarkBlue
<div style='background:#00008B;width:4em;height:4em;'></div>
Definition crgb.h:513
@ Maroon
<div style='background:#800000;width:4em;height:4em;'></div>
Definition crgb.h:577
@ Grey
<div style='background:#808080;width:4em;height:4em;'></div>
Definition crgb.h:546
FASTLED_FORCE_INLINE CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.hpp:146
constexpr CRGB nscale8_constexpr(const CRGB scaledown) const
Definition crgb.hpp:112
FASTLED_FORCE_INLINE CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Definition crgb.h:303
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54