FastLED 3.9.8
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 };
75 uint8_t raw[3];
76 };
77
78 static CRGB blend(const CRGB& p1, const CRGB& p2, fract8 amountOfP2);
79
83 FASTLED_FORCE_INLINE uint8_t& operator[] (uint8_t x)
84 {
85 return raw[x];
86 }
87
91 FASTLED_FORCE_INLINE const uint8_t& operator[] (uint8_t x) const
92 {
93 return raw[x];
94 }
95
98 FASTLED_FORCE_INLINE CRGB() = default;
99
104 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
105 : r(ir), g(ig), b(ib)
106 {
107 }
108
111 constexpr CRGB(uint32_t colorcode) noexcept
112 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
113 {
114 }
115
116 constexpr uint32_t as_uint32_t() const noexcept {
117 return uint32_t(0xff000000) |
118 (uint32_t{r} << 16) |
119 (uint32_t{g} << 8) |
120 uint32_t{b};
121 }
122
125 constexpr CRGB(LEDColorCorrection colorcode) noexcept
126 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
127 {
128 }
129
132 constexpr CRGB(ColorTemperature colorcode) noexcept
133 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
134 {
135 }
136
138 FASTLED_FORCE_INLINE CRGB(const CRGB& rhs) = default;
139
141 FASTLED_FORCE_INLINE CRGB(const CHSV& rhs)
142 {
143 hsv2rgb_rainbow( rhs, *this);
144 }
145
147 FASTLED_FORCE_INLINE CRGB& operator= (const CRGB& rhs) = default;
148
151 FASTLED_FORCE_INLINE CRGB& operator= (const uint32_t colorcode)
152 {
153 r = (colorcode >> 16) & 0xFF;
154 g = (colorcode >> 8) & 0xFF;
155 b = (colorcode >> 0) & 0xFF;
156 return *this;
157 }
158
163 FASTLED_FORCE_INLINE CRGB& setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
164 {
165 r = nr;
166 g = ng;
167 b = nb;
168 return *this;
169 }
170
175 FASTLED_FORCE_INLINE CRGB& setHSV (uint8_t hue, uint8_t sat, uint8_t val)
176 {
177 hsv2rgb_rainbow( CHSV(hue, sat, val), *this);
178 return *this;
179 }
180
184 FASTLED_FORCE_INLINE CRGB& setHue (uint8_t hue)
185 {
186 hsv2rgb_rainbow( CHSV(hue, 255, 255), *this);
187 return *this;
188 }
189
191 FASTLED_FORCE_INLINE CRGB& operator= (const CHSV& rhs)
192 {
193 hsv2rgb_rainbow( rhs, *this);
194 return *this;
195 }
196
199 FASTLED_FORCE_INLINE CRGB& setColorCode (uint32_t colorcode)
200 {
201 r = (colorcode >> 16) & 0xFF;
202 g = (colorcode >> 8) & 0xFF;
203 b = (colorcode >> 0) & 0xFF;
204 return *this;
205 }
206
207
209 FASTLED_FORCE_INLINE CRGB& operator+= (const CRGB& rhs);
210
215 FASTLED_FORCE_INLINE CRGB& addToRGB (uint8_t d);
216
218 FASTLED_FORCE_INLINE CRGB& operator-= (const CRGB& rhs);
219
224 FASTLED_FORCE_INLINE CRGB& subtractFromRGB(uint8_t d);
225
227 FASTLED_FORCE_INLINE CRGB& operator-- ();
228
230 FASTLED_FORCE_INLINE CRGB operator-- (int );
231
233 FASTLED_FORCE_INLINE CRGB& operator++ ();
234
236 FASTLED_FORCE_INLINE CRGB operator++ (int );
237
239 FASTLED_FORCE_INLINE CRGB& operator/= (uint8_t d )
240 {
241 r /= d;
242 g /= d;
243 b /= d;
244 return *this;
245 }
246
248 FASTLED_FORCE_INLINE CRGB& operator>>= (uint8_t d)
249 {
250 r >>= d;
251 g >>= d;
252 b >>= d;
253 return *this;
254 }
255
258 FASTLED_FORCE_INLINE CRGB& operator*= (uint8_t d);
259
266 FASTLED_FORCE_INLINE CRGB& nscale8_video (uint8_t scaledown);
267
270 FASTLED_FORCE_INLINE CRGB& operator%= (uint8_t scaledown);
271
274 FASTLED_FORCE_INLINE CRGB& fadeLightBy (uint8_t fadefactor );
275
280 FASTLED_FORCE_INLINE CRGB& nscale8 (uint8_t scaledown );
281
286 FASTLED_FORCE_INLINE CRGB& nscale8 (const CRGB & scaledown );
287
288 constexpr CRGB nscale8_constexpr (const CRGB scaledown ) const;
289
290
292 FASTLED_FORCE_INLINE CRGB scale8 (uint8_t scaledown ) const;
293
295 FASTLED_FORCE_INLINE CRGB scale8 (const CRGB & scaledown ) const;
296
299 FASTLED_FORCE_INLINE CRGB& fadeToBlackBy (uint8_t fadefactor );
300
302 FASTLED_FORCE_INLINE CRGB& operator|= (const CRGB& rhs )
303 {
304 if( rhs.r > r) r = rhs.r;
305 if( rhs.g > g) g = rhs.g;
306 if( rhs.b > b) b = rhs.b;
307 return *this;
308 }
309
311 FASTLED_FORCE_INLINE CRGB& operator|= (uint8_t d )
312 {
313 if( d > r) r = d;
314 if( d > g) g = d;
315 if( d > b) b = d;
316 return *this;
317 }
318
320 FASTLED_FORCE_INLINE CRGB& operator&= (const CRGB& rhs )
321 {
322 if( rhs.r < r) r = rhs.r;
323 if( rhs.g < g) g = rhs.g;
324 if( rhs.b < b) b = rhs.b;
325 return *this;
326 }
327
329 FASTLED_FORCE_INLINE CRGB& operator&= (uint8_t d )
330 {
331 if( d < r) r = d;
332 if( d < g) g = d;
333 if( d < b) b = d;
334 return *this;
335 }
336
338 constexpr explicit operator bool() const
339 {
340 return r || g || b;
341 }
342
344 constexpr explicit operator uint32_t() const
345 {
346 return uint32_t(0xff000000) |
347 (uint32_t{r} << 16) |
348 (uint32_t{g} << 8) |
349 uint32_t{b};
350 }
351
353 constexpr CRGB operator-() const
354 {
355 return CRGB(255 - r, 255 - g, 255 - b);
356 }
357
358#if (defined SmartMatrix_h || defined SmartMatrix3_h)
361 operator rgb24() const {
362 rgb24 ret;
363 ret.red = r;
364 ret.green = g;
365 ret.blue = b;
366 return ret;
367 }
368#endif
369
370 fl::Str toString() const;
371
374 FASTLED_FORCE_INLINE uint8_t getLuma() const;
375
377 FASTLED_FORCE_INLINE uint8_t getAverageLight() const;
378
384 FASTLED_FORCE_INLINE void maximizeBrightness( uint8_t limit = 255 ) {
385 uint8_t max = red;
386 if( green > max) max = green;
387 if( blue > max) max = blue;
388
389 // stop div/0 when color is black
390 if(max > 0) {
391 uint16_t factor = ((uint16_t)(limit) * 256) / max;
392 red = (red * factor) / 256;
393 green = (green * factor) / 256;
394 blue = (blue * factor) / 256;
395 }
396 }
397
403 static CRGB computeAdjustment(uint8_t scale, const CRGB & colorCorrection, const CRGB & colorTemperature);
404
406 FASTLED_FORCE_INLINE CRGB lerp8( const CRGB& other, fract8 frac) const;
407
409 FASTLED_FORCE_INLINE CRGB lerp16( const CRGB& other, fract16 frac) const;
411 FASTLED_FORCE_INLINE uint8_t getParity()
412 {
413 uint8_t sum = r + g + b;
414 return (sum & 0x01);
415 }
416
439 FASTLED_FORCE_INLINE void setParity( uint8_t parity)
440 {
441 uint8_t curparity = getParity();
442
443 if( parity == curparity) return;
444
445 if( parity ) {
446 // going 'up'
447 if( (b > 0) && (b < 255)) {
448 if( r == g && g == b) {
449 ++r;
450 ++g;
451 }
452 ++b;
453 } else if( (r > 0) && (r < 255)) {
454 ++r;
455 } else if( (g > 0) && (g < 255)) {
456 ++g;
457 } else {
458 if( r == g && g == b) {
459 r ^= 0x01;
460 g ^= 0x01;
461 }
462 b ^= 0x01;
463 }
464 } else {
465 // going 'down'
466 if( b > 1) {
467 if( r == g && g == b) {
468 --r;
469 --g;
470 }
471 --b;
472 } else if( g > 1) {
473 --g;
474 } else if( r > 1) {
475 --r;
476 } else {
477 if( r == g && g == b) {
478 r ^= 0x01;
479 g ^= 0x01;
480 }
481 b ^= 0x01;
482 }
483 }
484 }
485
487 typedef enum {
488 AliceBlue=0xF0F8FF,
489 Amethyst=0x9966CC,
490 AntiqueWhite=0xFAEBD7,
491 Aqua=0x00FFFF,
492 Aquamarine=0x7FFFD4,
493 Azure=0xF0FFFF,
494 Beige=0xF5F5DC,
495 Bisque=0xFFE4C4,
496 Black=0x000000,
497 BlanchedAlmond=0xFFEBCD,
498 Blue=0x0000FF,
499 BlueViolet=0x8A2BE2,
500 Brown=0xA52A2A,
501 BurlyWood=0xDEB887,
502 CadetBlue=0x5F9EA0,
503 Chartreuse=0x7FFF00,
504 Chocolate=0xD2691E,
505 Coral=0xFF7F50,
506 CornflowerBlue=0x6495ED,
507 Cornsilk=0xFFF8DC,
508 Crimson=0xDC143C,
509 Cyan=0x00FFFF,
510 DarkBlue=0x00008B,
511 DarkCyan=0x008B8B,
512 DarkGoldenrod=0xB8860B,
513 DarkGray=0xA9A9A9,
514 DarkGrey=0xA9A9A9,
515 DarkGreen=0x006400,
516 DarkKhaki=0xBDB76B,
517 DarkMagenta=0x8B008B,
518 DarkOliveGreen=0x556B2F,
519 DarkOrange=0xFF8C00,
520 DarkOrchid=0x9932CC,
521 DarkRed=0x8B0000,
522 DarkSalmon=0xE9967A,
523 DarkSeaGreen=0x8FBC8F,
524 DarkSlateBlue=0x483D8B,
525 DarkSlateGray=0x2F4F4F,
526 DarkSlateGrey=0x2F4F4F,
527 DarkTurquoise=0x00CED1,
528 DarkViolet=0x9400D3,
529 DeepPink=0xFF1493,
530 DeepSkyBlue=0x00BFFF,
531 DimGray=0x696969,
532 DimGrey=0x696969,
533 DodgerBlue=0x1E90FF,
534 FireBrick=0xB22222,
535 FloralWhite=0xFFFAF0,
536 ForestGreen=0x228B22,
537 Fuchsia=0xFF00FF,
538 Gainsboro=0xDCDCDC,
539 GhostWhite=0xF8F8FF,
540 Gold=0xFFD700,
541 Goldenrod=0xDAA520,
542 Gray=0x808080,
543 Grey=0x808080,
544 Green=0x008000,
545 GreenYellow=0xADFF2F,
546 Honeydew=0xF0FFF0,
547 HotPink=0xFF69B4,
548 IndianRed=0xCD5C5C,
549 Indigo=0x4B0082,
550 Ivory=0xFFFFF0,
551 Khaki=0xF0E68C,
552 Lavender=0xE6E6FA,
553 LavenderBlush=0xFFF0F5,
554 LawnGreen=0x7CFC00,
555 LemonChiffon=0xFFFACD,
556 LightBlue=0xADD8E6,
557 LightCoral=0xF08080,
558 LightCyan=0xE0FFFF,
560 LightGreen=0x90EE90,
561 LightGrey=0xD3D3D3,
562 LightPink=0xFFB6C1,
563 LightSalmon=0xFFA07A,
564 LightSeaGreen=0x20B2AA,
565 LightSkyBlue=0x87CEFA,
566 LightSlateGray=0x778899,
567 LightSlateGrey=0x778899,
568 LightSteelBlue=0xB0C4DE,
569 LightYellow=0xFFFFE0,
570 Lime=0x00FF00,
571 LimeGreen=0x32CD32,
572 Linen=0xFAF0E6,
573 Magenta=0xFF00FF,
574 Maroon=0x800000,
576 MediumBlue=0x0000CD,
577 MediumOrchid=0xBA55D3,
578 MediumPurple=0x9370DB,
579 MediumSeaGreen=0x3CB371,
584 MidnightBlue=0x191970,
585 MintCream=0xF5FFFA,
586 MistyRose=0xFFE4E1,
587 Moccasin=0xFFE4B5,
588 NavajoWhite=0xFFDEAD,
589 Navy=0x000080,
590 OldLace=0xFDF5E6,
591 Olive=0x808000,
592 OliveDrab=0x6B8E23,
593 Orange=0xFFA500,
594 OrangeRed=0xFF4500,
595 Orchid=0xDA70D6,
596 PaleGoldenrod=0xEEE8AA,
597 PaleGreen=0x98FB98,
598 PaleTurquoise=0xAFEEEE,
599 PaleVioletRed=0xDB7093,
600 PapayaWhip=0xFFEFD5,
601 PeachPuff=0xFFDAB9,
602 Peru=0xCD853F,
603 Pink=0xFFC0CB,
604 Plaid=0xCC5533,
605 Plum=0xDDA0DD,
606 PowderBlue=0xB0E0E6,
607 Purple=0x800080,
608 Red=0xFF0000,
609 RosyBrown=0xBC8F8F,
610 RoyalBlue=0x4169E1,
611 SaddleBrown=0x8B4513,
612 Salmon=0xFA8072,
613 SandyBrown=0xF4A460,
614 SeaGreen=0x2E8B57,
615 Seashell=0xFFF5EE,
616 Sienna=0xA0522D,
617 Silver=0xC0C0C0,
618 SkyBlue=0x87CEEB,
619 SlateBlue=0x6A5ACD,
620 SlateGray=0x708090,
621 SlateGrey=0x708090,
622 Snow=0xFFFAFA,
623 SpringGreen=0x00FF7F,
624 SteelBlue=0x4682B4,
625 Tan=0xD2B48C,
626 Teal=0x008080,
627 Thistle=0xD8BFD8,
628 Tomato=0xFF6347,
629 Turquoise=0x40E0D0,
630 Violet=0xEE82EE,
631 Wheat=0xF5DEB3,
632 White=0xFFFFFF,
633 WhiteSmoke=0xF5F5F5,
634 Yellow=0xFFFF00,
635 YellowGreen=0x9ACD32,
636
637 // LED RGB color that roughly approximates
638 // the color of incandescent fairy lights,
639 // assuming that you're using FastLED
640 // color correction on your LEDs (recommended).
641 FairyLight=0xFFE42D,
642
643 // If you are using no color correction, use this
644 FairyLightNCC=0xFF9D2A
645
647};
648
649
651FASTLED_FORCE_INLINE bool operator== (const CRGB& lhs, const CRGB& rhs)
652{
653 return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
654}
655
657FASTLED_FORCE_INLINE bool operator!= (const CRGB& lhs, const CRGB& rhs)
658{
659 return !(lhs == rhs);
660}
661
663FASTLED_FORCE_INLINE bool operator== (const CHSV& lhs, const CHSV& rhs)
664{
665 return (lhs.h == rhs.h) && (lhs.s == rhs.s) && (lhs.v == rhs.v);
666}
667
669FASTLED_FORCE_INLINE bool operator!= (const CHSV& lhs, const CHSV& rhs)
670{
671 return !(lhs == rhs);
672}
673
675FASTLED_FORCE_INLINE bool operator< (const CRGB& lhs, const CRGB& rhs)
676{
677 uint16_t sl, sr;
678 sl = lhs.r + lhs.g + lhs.b;
679 sr = rhs.r + rhs.g + rhs.b;
680 return sl < sr;
681}
682
684FASTLED_FORCE_INLINE bool operator> (const CRGB& lhs, const CRGB& rhs)
685{
686 uint16_t sl, sr;
687 sl = lhs.r + lhs.g + lhs.b;
688 sr = rhs.r + rhs.g + rhs.b;
689 return sl > sr;
690}
691
693FASTLED_FORCE_INLINE bool operator>= (const CRGB& lhs, const CRGB& rhs)
694{
695 uint16_t sl, sr;
696 sl = lhs.r + lhs.g + lhs.b;
697 sr = rhs.r + rhs.g + rhs.b;
698 return sl >= sr;
699}
700
702FASTLED_FORCE_INLINE bool operator<= (const CRGB& lhs, const CRGB& rhs)
703{
704 uint16_t sl, sr;
705 sl = lhs.r + lhs.g + lhs.b;
706 sr = rhs.r + rhs.g + rhs.b;
707 return sl <= sr;
708}
709
710
711
713FASTLED_FORCE_INLINE CRGB operator/( const CRGB& p1, uint8_t d)
714{
715 return CRGB( p1.r/d, p1.g/d, p1.b/d);
716}
717
718
720FASTLED_FORCE_INLINE CRGB operator&( const CRGB& p1, const CRGB& p2)
721{
722 return CRGB( p1.r < p2.r ? p1.r : p2.r,
723 p1.g < p2.g ? p1.g : p2.g,
724 p1.b < p2.b ? p1.b : p2.b);
725}
726
728FASTLED_FORCE_INLINE CRGB operator|( const CRGB& p1, const CRGB& p2)
729{
730 return CRGB( p1.r > p2.r ? p1.r : p2.r,
731 p1.g > p2.g ? p1.g : p2.g,
732 p1.b > p2.b ? p1.b : p2.b);
733}
734
736FASTLED_FORCE_INLINE CRGB operator+( const CRGB& p1, const CRGB& p2);
737
739FASTLED_FORCE_INLINE CRGB operator-( const CRGB& p1, const CRGB& p2);
740
742FASTLED_FORCE_INLINE CRGB operator*( const CRGB& p1, uint8_t d);
743
745FASTLED_FORCE_INLINE CRGB operator%( const CRGB& p1, uint8_t d);
746
748
749
751
752
Defines the hue, saturation, and value (HSV) pixel struct.
Definition str.h:336
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:657
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:702
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:651
FASTLED_FORCE_INLINE CRGB operator/(const CRGB &p1, uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:713
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
Definition crgb.hpp:229
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:213
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:675
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:728
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:720
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:684
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:693
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:221
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:205
Defines fractional types used for lib8tion functions.
Implements the FastLED namespace macros.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
Definition namespace.h:16
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Definition namespace.h:14
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
uint8_t v
Color value (brightness).
Definition chsv.h:38
uint8_t h
Color hue.
Definition chsv.h:24
uint8_t s
Color saturation.
Definition chsv.h:31
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54
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.
FASTLED_FORCE_INLINE uint8_t getLuma() const
Get the "luma" of a CRGB object.
Definition crgb.hpp:157
uint8_t raw[3]
Access the red, green, and blue data as an array.
Definition crgb.h:75
uint8_t r
Red channel value.
Definition crgb.h:58
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:411
FASTLED_FORCE_INLINE CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:239
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:132
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
FASTLED_FORCE_INLINE CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.hpp:111
constexpr CRGB(uint32_t colorcode) noexcept
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
Definition crgb.h:111
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:192
FASTLED_FORCE_INLINE CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
Definition crgb.hpp:39
FASTLED_FORCE_INLINE CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
Definition crgb.h:163
FASTLED_FORCE_INLINE CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
Definition crgb.h:199
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:439
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:141
FASTLED_FORCE_INLINE CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
Definition crgb.h:175
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:181
uint8_t g
Green channel value.
Definition crgb.h:62
uint8_t red
Red channel value.
Definition crgb.h:59
FASTLED_FORCE_INLINE CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
Definition crgb.h:248
constexpr CRGB operator-() const
Invert each channel.
Definition crgb.h:353
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 uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
Definition crgb.h:83
uint8_t blue
Blue channel value.
Definition crgb.h:67
FASTLED_FORCE_INLINE CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
Definition crgb.h:320
FASTLED_FORCE_INLINE uint8_t getAverageLight() const
Get the average of the R, G, and B values.
Definition crgb.hpp:168
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:104
uint8_t b
Blue channel value.
Definition crgb.h:66
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:135
uint8_t green
Green channel value.
Definition crgb.h:63
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
FASTLED_FORCE_INLINE CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
Definition crgb.h:184
FASTLED_FORCE_INLINE CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
Definition crgb.hpp:84
FASTLED_FORCE_INLINE void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
Definition crgb.h:384
constexpr CRGB(LEDColorCorrection colorcode) noexcept
Allow construction from a LEDColorCorrection enum.
Definition crgb.h:125
HTMLColorCode
Predefined RGB colors.
Definition crgb.h:487
@ DarkGray
Definition crgb.h:513
@ Sienna
Definition crgb.h:616
@ Plum
Definition crgb.h:605
@ GhostWhite
Definition crgb.h:539
@ Tan
Definition crgb.h:625
@ Gold
Definition crgb.h:540
@ DarkRed
Definition crgb.h:521
@ DarkSlateGray
Definition crgb.h:525
@ OldLace
Definition crgb.h:590
@ Aquamarine
Definition crgb.h:492
@ Violet
Definition crgb.h:630
@ Salmon
Definition crgb.h:612
@ Thistle
Definition crgb.h:627
@ Cornsilk
Definition crgb.h:507
@ MediumVioletRed
Definition crgb.h:583
@ Coral
Definition crgb.h:505
@ LightPink
Definition crgb.h:562
@ DarkGrey
Definition crgb.h:514
@ SlateGrey
Definition crgb.h:621
@ NavajoWhite
Definition crgb.h:588
@ PaleVioletRed
Definition crgb.h:599
@ HotPink
Definition crgb.h:547
@ BlanchedAlmond
Definition crgb.h:497
@ RosyBrown
Definition crgb.h:609
@ White
Definition crgb.h:632
@ Moccasin
Definition crgb.h:587
@ LightYellow
Definition crgb.h:569
@ Bisque
Definition crgb.h:495
@ DeepPink
Definition crgb.h:529
@ Wheat
Definition crgb.h:631
@ MediumOrchid
Definition crgb.h:577
@ Goldenrod
Definition crgb.h:541
@ Orange
Definition crgb.h:593
@ MediumSpringGreen
Definition crgb.h:581
@ Seashell
Definition crgb.h:615
@ DarkViolet
Definition crgb.h:528
@ Ivory
Definition crgb.h:550
@ Teal
Definition crgb.h:626
@ Gray
Definition crgb.h:542
@ MistyRose
Definition crgb.h:586
@ SlateBlue
Definition crgb.h:619
@ Silver
Definition crgb.h:617
@ Purple
Definition crgb.h:607
@ DarkKhaki
Definition crgb.h:516
@ SaddleBrown
Definition crgb.h:611
@ LemonChiffon
Definition crgb.h:555
@ Magenta
Definition crgb.h:573
@ Beige
Definition crgb.h:494
@ Crimson
Definition crgb.h:508
@ MediumAquamarine
Definition crgb.h:575
@ LawnGreen
Definition crgb.h:554
@ DodgerBlue
Definition crgb.h:533
@ Tomato
Definition crgb.h:628
@ Fuchsia
Definition crgb.h:537
@ Aqua
Definition crgb.h:491
@ Brown
Definition crgb.h:500
@ Pink
Definition crgb.h:603
@ Lavender
Definition crgb.h:552
@ YellowGreen
Definition crgb.h:635
@ DeepSkyBlue
Definition crgb.h:530
@ Turquoise
Definition crgb.h:629
@ SandyBrown
Definition crgb.h:613
@ MediumSlateBlue
Definition crgb.h:580
@ PeachPuff
Definition crgb.h:601
@ Orchid
Definition crgb.h:595
@ Green
Definition crgb.h:544
@ SteelBlue
Definition crgb.h:624
@ CornflowerBlue
Definition crgb.h:506
@ DarkSalmon
Definition crgb.h:522
@ SkyBlue
Definition crgb.h:618
@ LightSalmon
Definition crgb.h:563
@ RoyalBlue
Definition crgb.h:610
@ DarkSlateGrey
Definition crgb.h:526
@ Navy
Definition crgb.h:589
@ Lime
Definition crgb.h:570
@ LightCoral
Definition crgb.h:557
@ PaleTurquoise
Definition crgb.h:598
@ BurlyWood
Definition crgb.h:501
@ DarkTurquoise
Definition crgb.h:527
@ DarkMagenta
Definition crgb.h:517
@ LightSeaGreen
Definition crgb.h:564
@ MidnightBlue
Definition crgb.h:584
@ LightSlateGray
Definition crgb.h:566
@ Chocolate
Definition crgb.h:504
@ Linen
Definition crgb.h:572
@ SeaGreen
Definition crgb.h:614
@ Cyan
Definition crgb.h:509
@ AntiqueWhite
Definition crgb.h:490
@ LimeGreen
Definition crgb.h:571
@ MediumTurquoise
Definition crgb.h:582
@ LightGreen
Definition crgb.h:560
@ MediumSeaGreen
Definition crgb.h:579
@ PaleGreen
Definition crgb.h:597
@ FireBrick
Definition crgb.h:534
@ Amethyst
Definition crgb.h:489
@ LightSteelBlue
Definition crgb.h:568
@ LightGrey
Definition crgb.h:561
@ BlueViolet
Definition crgb.h:499
@ Indigo
Definition crgb.h:549
@ LightCyan
Definition crgb.h:558
@ Olive
Definition crgb.h:591
@ PapayaWhip
Definition crgb.h:600
@ Azure
Definition crgb.h:493
@ Blue
Definition crgb.h:498
@ DarkOrchid
Definition crgb.h:520
@ Red
Definition crgb.h:608
@ PowderBlue
Definition crgb.h:606
@ IndianRed
Definition crgb.h:548
@ FairyLight
Definition crgb.h:641
@ DarkGoldenrod
Definition crgb.h:512
@ LightSkyBlue
Definition crgb.h:565
@ DarkSlateBlue
Definition crgb.h:524
@ MediumBlue
Definition crgb.h:576
@ Black
Definition crgb.h:496
@ LavenderBlush
Definition crgb.h:553
@ DarkOrange
Definition crgb.h:519
@ CadetBlue
Definition crgb.h:502
@ SlateGray
Definition crgb.h:620
@ OliveDrab
Definition crgb.h:592
@ Plaid
Definition crgb.h:604
@ SpringGreen
Definition crgb.h:623
@ Honeydew
Definition crgb.h:546
@ Gainsboro
Definition crgb.h:538
@ MediumPurple
Definition crgb.h:578
@ Yellow
Definition crgb.h:634
@ DimGrey
Definition crgb.h:532
@ FairyLightNCC
Definition crgb.h:644
@ DarkOliveGreen
Definition crgb.h:518
@ LightGoldenrodYellow
Definition crgb.h:559
@ LightSlateGrey
Definition crgb.h:567
@ Peru
Definition crgb.h:602
@ AliceBlue
Definition crgb.h:488
@ PaleGoldenrod
Definition crgb.h:596
@ DarkSeaGreen
Definition crgb.h:523
@ LightBlue
Definition crgb.h:556
@ FloralWhite
Definition crgb.h:535
@ Chartreuse
Definition crgb.h:503
@ DimGray
Definition crgb.h:531
@ OrangeRed
Definition crgb.h:594
@ ForestGreen
Definition crgb.h:536
@ Khaki
Definition crgb.h:551
@ MintCream
Definition crgb.h:585
@ DarkCyan
Definition crgb.h:511
@ Snow
Definition crgb.h:622
@ DarkGreen
Definition crgb.h:515
@ GreenYellow
Definition crgb.h:545
@ WhiteSmoke
Definition crgb.h:633
@ DarkBlue
Definition crgb.h:510
@ Maroon
Definition crgb.h:574
@ Grey
Definition crgb.h:543
FASTLED_FORCE_INLINE CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.hpp:151
FASTLED_FORCE_INLINE CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Definition crgb.h:302