FastLED 3.9.3
Loading...
Searching...
No Matches
crgb.h
1
2#pragma once
3
4#include <stdint.h>
5
6#include "chsv.h"
7#include "namespace.h"
8#include "color.h"
9#include "lib8tion/types.h"
10#include "force_inline.h"
11#include "template_magic.h"
12
13
14FASTLED_NAMESPACE_BEGIN
15
16// Whether to allow HD_COLOR_MIXING
17#ifndef FASTLED_HD_COLOR_MIXING
18#ifdef __AVR__
19// Saves some memory on these constrained devices.
20#define FASTLED_HD_COLOR_MIXING 0
21#else
22#define FASTLED_HD_COLOR_MIXING 1
23#endif // __AVR__
24#endif // FASTLED_HD_COLOR_MIXING
25
26
27struct CRGB;
28
32
35extern void hsv2rgb_rainbow( const CHSV& hsv, CRGB& rgb);
36
37
39struct CRGB {
40 union {
41 struct {
42 union {
43 uint8_t r;
44 uint8_t red;
45 };
46 union {
47 uint8_t g;
48 uint8_t green;
49 };
50 union {
51 uint8_t b;
52 uint8_t blue;
53 };
54 };
60 uint8_t raw[3];
61 };
62
63 static CRGB blend(const CRGB& p1, const CRGB& p2, fract8 amountOfP2);
64
68 FASTLED_FORCE_INLINE uint8_t& operator[] (uint8_t x)
69 {
70 return raw[x];
71 }
72
76 FASTLED_FORCE_INLINE const uint8_t& operator[] (uint8_t x) const
77 {
78 return raw[x];
79 }
80
83 FASTLED_FORCE_INLINE CRGB() = default;
84
89 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
90 : r(ir), g(ig), b(ib)
91 {
92 }
93
96 constexpr CRGB(uint32_t colorcode) noexcept
97 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
98 {
99 }
100
101 constexpr uint32_t as_uint32_t() const noexcept {
102 return uint32_t(0xff000000) |
103 (uint32_t{r} << 16) |
104 (uint32_t{g} << 8) |
105 uint32_t{b};
106 }
107
110 constexpr CRGB(LEDColorCorrection colorcode) noexcept
111 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
112 {
113 }
114
117 constexpr CRGB(ColorTemperature colorcode) noexcept
118 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
119 {
120 }
121
123 FASTLED_FORCE_INLINE CRGB(const CRGB& rhs) = default;
124
126 FASTLED_FORCE_INLINE CRGB(const CHSV& rhs)
127 {
128 hsv2rgb_rainbow( rhs, *this);
129 }
130
132 FASTLED_FORCE_INLINE CRGB& operator= (const CRGB& rhs) = default;
133
136 FASTLED_FORCE_INLINE CRGB& operator= (const uint32_t colorcode)
137 {
138 r = (colorcode >> 16) & 0xFF;
139 g = (colorcode >> 8) & 0xFF;
140 b = (colorcode >> 0) & 0xFF;
141 return *this;
142 }
143
148 FASTLED_FORCE_INLINE CRGB& setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
149 {
150 r = nr;
151 g = ng;
152 b = nb;
153 return *this;
154 }
155
160 FASTLED_FORCE_INLINE CRGB& setHSV (uint8_t hue, uint8_t sat, uint8_t val)
161 {
162 hsv2rgb_rainbow( CHSV(hue, sat, val), *this);
163 return *this;
164 }
165
169 FASTLED_FORCE_INLINE CRGB& setHue (uint8_t hue)
170 {
171 hsv2rgb_rainbow( CHSV(hue, 255, 255), *this);
172 return *this;
173 }
174
176 FASTLED_FORCE_INLINE CRGB& operator= (const CHSV& rhs)
177 {
178 hsv2rgb_rainbow( rhs, *this);
179 return *this;
180 }
181
184 FASTLED_FORCE_INLINE CRGB& setColorCode (uint32_t colorcode)
185 {
186 r = (colorcode >> 16) & 0xFF;
187 g = (colorcode >> 8) & 0xFF;
188 b = (colorcode >> 0) & 0xFF;
189 return *this;
190 }
191
192
194 FASTLED_FORCE_INLINE CRGB& operator+= (const CRGB& rhs);
195
200 FASTLED_FORCE_INLINE CRGB& addToRGB (uint8_t d);
201
203 FASTLED_FORCE_INLINE CRGB& operator-= (const CRGB& rhs);
204
209 FASTLED_FORCE_INLINE CRGB& subtractFromRGB(uint8_t d);
210
212 FASTLED_FORCE_INLINE CRGB& operator-- ();
213
215 FASTLED_FORCE_INLINE CRGB operator-- (int );
216
218 FASTLED_FORCE_INLINE CRGB& operator++ ();
219
221 FASTLED_FORCE_INLINE CRGB operator++ (int );
222
224 FASTLED_FORCE_INLINE CRGB& operator/= (uint8_t d )
225 {
226 r /= d;
227 g /= d;
228 b /= d;
229 return *this;
230 }
231
233 FASTLED_FORCE_INLINE CRGB& operator>>= (uint8_t d)
234 {
235 r >>= d;
236 g >>= d;
237 b >>= d;
238 return *this;
239 }
240
243 FASTLED_FORCE_INLINE CRGB& operator*= (uint8_t d);
244
251 FASTLED_FORCE_INLINE CRGB& nscale8_video (uint8_t scaledown);
252
255 FASTLED_FORCE_INLINE CRGB& operator%= (uint8_t scaledown);
256
259 FASTLED_FORCE_INLINE CRGB& fadeLightBy (uint8_t fadefactor );
260
265 FASTLED_FORCE_INLINE CRGB& nscale8 (uint8_t scaledown );
266
271 FASTLED_FORCE_INLINE CRGB& nscale8 (const CRGB & scaledown );
272
273 constexpr CRGB nscale8_constexpr (const CRGB scaledown ) const;
274
275
277 FASTLED_FORCE_INLINE CRGB scale8 (uint8_t scaledown ) const;
278
280 FASTLED_FORCE_INLINE CRGB scale8 (const CRGB & scaledown ) const;
281
284 FASTLED_FORCE_INLINE CRGB& fadeToBlackBy (uint8_t fadefactor );
285
287 FASTLED_FORCE_INLINE CRGB& operator|= (const CRGB& rhs )
288 {
289 if( rhs.r > r) r = rhs.r;
290 if( rhs.g > g) g = rhs.g;
291 if( rhs.b > b) b = rhs.b;
292 return *this;
293 }
294
296 FASTLED_FORCE_INLINE CRGB& operator|= (uint8_t d )
297 {
298 if( d > r) r = d;
299 if( d > g) g = d;
300 if( d > b) b = d;
301 return *this;
302 }
303
305 FASTLED_FORCE_INLINE CRGB& operator&= (const CRGB& rhs )
306 {
307 if( rhs.r < r) r = rhs.r;
308 if( rhs.g < g) g = rhs.g;
309 if( rhs.b < b) b = rhs.b;
310 return *this;
311 }
312
314 FASTLED_FORCE_INLINE CRGB& operator&= (uint8_t d )
315 {
316 if( d < r) r = d;
317 if( d < g) g = d;
318 if( d < b) b = d;
319 return *this;
320 }
321
323 constexpr explicit operator bool() const
324 {
325 return r || g || b;
326 }
327
329 constexpr explicit operator uint32_t() const
330 {
331 return uint32_t(0xff000000) |
332 (uint32_t{r} << 16) |
333 (uint32_t{g} << 8) |
334 uint32_t{b};
335 }
336
338 constexpr CRGB operator-() const
339 {
340 return CRGB(255 - r, 255 - g, 255 - b);
341 }
342
343#if (defined SmartMatrix_h || defined SmartMatrix3_h)
346 operator rgb24() const {
347 rgb24 ret;
348 ret.red = r;
349 ret.green = g;
350 ret.blue = b;
351 return ret;
352 }
353#endif
354
357 FASTLED_FORCE_INLINE uint8_t getLuma() const;
358
360 FASTLED_FORCE_INLINE uint8_t getAverageLight() const;
361
367 FASTLED_FORCE_INLINE void maximizeBrightness( uint8_t limit = 255 ) {
368 uint8_t max = red;
369 if( green > max) max = green;
370 if( blue > max) max = blue;
371
372 // stop div/0 when color is black
373 if(max > 0) {
374 uint16_t factor = ((uint16_t)(limit) * 256) / max;
375 red = (red * factor) / 256;
376 green = (green * factor) / 256;
377 blue = (blue * factor) / 256;
378 }
379 }
380
386 static CRGB computeAdjustment(uint8_t scale, const CRGB & colorCorrection, const CRGB & colorTemperature);
387
389 FASTLED_FORCE_INLINE CRGB lerp8( const CRGB& other, fract8 frac) const;
390
392 FASTLED_FORCE_INLINE CRGB lerp16( const CRGB& other, fract16 frac) const;
394 FASTLED_FORCE_INLINE uint8_t getParity()
395 {
396 uint8_t sum = r + g + b;
397 return (sum & 0x01);
398 }
399
422 FASTLED_FORCE_INLINE void setParity( uint8_t parity)
423 {
424 uint8_t curparity = getParity();
425
426 if( parity == curparity) return;
427
428 if( parity ) {
429 // going 'up'
430 if( (b > 0) && (b < 255)) {
431 if( r == g && g == b) {
432 ++r;
433 ++g;
434 }
435 ++b;
436 } else if( (r > 0) && (r < 255)) {
437 ++r;
438 } else if( (g > 0) && (g < 255)) {
439 ++g;
440 } else {
441 if( r == g && g == b) {
442 r ^= 0x01;
443 g ^= 0x01;
444 }
445 b ^= 0x01;
446 }
447 } else {
448 // going 'down'
449 if( b > 1) {
450 if( r == g && g == b) {
451 --r;
452 --g;
453 }
454 --b;
455 } else if( g > 1) {
456 --g;
457 } else if( r > 1) {
458 --r;
459 } else {
460 if( r == g && g == b) {
461 r ^= 0x01;
462 g ^= 0x01;
463 }
464 b ^= 0x01;
465 }
466 }
467 }
468
470 typedef enum {
471 AliceBlue=0xF0F8FF,
472 Amethyst=0x9966CC,
473 AntiqueWhite=0xFAEBD7,
474 Aqua=0x00FFFF,
475 Aquamarine=0x7FFFD4,
476 Azure=0xF0FFFF,
477 Beige=0xF5F5DC,
478 Bisque=0xFFE4C4,
479 Black=0x000000,
480 BlanchedAlmond=0xFFEBCD,
481 Blue=0x0000FF,
482 BlueViolet=0x8A2BE2,
483 Brown=0xA52A2A,
484 BurlyWood=0xDEB887,
485 CadetBlue=0x5F9EA0,
486 Chartreuse=0x7FFF00,
487 Chocolate=0xD2691E,
488 Coral=0xFF7F50,
489 CornflowerBlue=0x6495ED,
490 Cornsilk=0xFFF8DC,
491 Crimson=0xDC143C,
492 Cyan=0x00FFFF,
493 DarkBlue=0x00008B,
494 DarkCyan=0x008B8B,
495 DarkGoldenrod=0xB8860B,
496 DarkGray=0xA9A9A9,
497 DarkGrey=0xA9A9A9,
498 DarkGreen=0x006400,
499 DarkKhaki=0xBDB76B,
500 DarkMagenta=0x8B008B,
501 DarkOliveGreen=0x556B2F,
502 DarkOrange=0xFF8C00,
503 DarkOrchid=0x9932CC,
504 DarkRed=0x8B0000,
505 DarkSalmon=0xE9967A,
506 DarkSeaGreen=0x8FBC8F,
507 DarkSlateBlue=0x483D8B,
508 DarkSlateGray=0x2F4F4F,
509 DarkSlateGrey=0x2F4F4F,
510 DarkTurquoise=0x00CED1,
511 DarkViolet=0x9400D3,
512 DeepPink=0xFF1493,
513 DeepSkyBlue=0x00BFFF,
514 DimGray=0x696969,
515 DimGrey=0x696969,
516 DodgerBlue=0x1E90FF,
517 FireBrick=0xB22222,
518 FloralWhite=0xFFFAF0,
519 ForestGreen=0x228B22,
520 Fuchsia=0xFF00FF,
521 Gainsboro=0xDCDCDC,
522 GhostWhite=0xF8F8FF,
523 Gold=0xFFD700,
524 Goldenrod=0xDAA520,
525 Gray=0x808080,
526 Grey=0x808080,
527 Green=0x008000,
528 GreenYellow=0xADFF2F,
529 Honeydew=0xF0FFF0,
530 HotPink=0xFF69B4,
531 IndianRed=0xCD5C5C,
532 Indigo=0x4B0082,
533 Ivory=0xFFFFF0,
534 Khaki=0xF0E68C,
535 Lavender=0xE6E6FA,
536 LavenderBlush=0xFFF0F5,
537 LawnGreen=0x7CFC00,
538 LemonChiffon=0xFFFACD,
539 LightBlue=0xADD8E6,
540 LightCoral=0xF08080,
541 LightCyan=0xE0FFFF,
543 LightGreen=0x90EE90,
544 LightGrey=0xD3D3D3,
545 LightPink=0xFFB6C1,
546 LightSalmon=0xFFA07A,
547 LightSeaGreen=0x20B2AA,
548 LightSkyBlue=0x87CEFA,
549 LightSlateGray=0x778899,
550 LightSlateGrey=0x778899,
551 LightSteelBlue=0xB0C4DE,
552 LightYellow=0xFFFFE0,
553 Lime=0x00FF00,
554 LimeGreen=0x32CD32,
555 Linen=0xFAF0E6,
556 Magenta=0xFF00FF,
557 Maroon=0x800000,
559 MediumBlue=0x0000CD,
560 MediumOrchid=0xBA55D3,
561 MediumPurple=0x9370DB,
562 MediumSeaGreen=0x3CB371,
567 MidnightBlue=0x191970,
568 MintCream=0xF5FFFA,
569 MistyRose=0xFFE4E1,
570 Moccasin=0xFFE4B5,
571 NavajoWhite=0xFFDEAD,
572 Navy=0x000080,
573 OldLace=0xFDF5E6,
574 Olive=0x808000,
575 OliveDrab=0x6B8E23,
576 Orange=0xFFA500,
577 OrangeRed=0xFF4500,
578 Orchid=0xDA70D6,
579 PaleGoldenrod=0xEEE8AA,
580 PaleGreen=0x98FB98,
581 PaleTurquoise=0xAFEEEE,
582 PaleVioletRed=0xDB7093,
583 PapayaWhip=0xFFEFD5,
584 PeachPuff=0xFFDAB9,
585 Peru=0xCD853F,
586 Pink=0xFFC0CB,
587 Plaid=0xCC5533,
588 Plum=0xDDA0DD,
589 PowderBlue=0xB0E0E6,
590 Purple=0x800080,
591 Red=0xFF0000,
592 RosyBrown=0xBC8F8F,
593 RoyalBlue=0x4169E1,
594 SaddleBrown=0x8B4513,
595 Salmon=0xFA8072,
596 SandyBrown=0xF4A460,
597 SeaGreen=0x2E8B57,
598 Seashell=0xFFF5EE,
599 Sienna=0xA0522D,
600 Silver=0xC0C0C0,
601 SkyBlue=0x87CEEB,
602 SlateBlue=0x6A5ACD,
603 SlateGray=0x708090,
604 SlateGrey=0x708090,
605 Snow=0xFFFAFA,
606 SpringGreen=0x00FF7F,
607 SteelBlue=0x4682B4,
608 Tan=0xD2B48C,
609 Teal=0x008080,
610 Thistle=0xD8BFD8,
611 Tomato=0xFF6347,
612 Turquoise=0x40E0D0,
613 Violet=0xEE82EE,
614 Wheat=0xF5DEB3,
615 White=0xFFFFFF,
616 WhiteSmoke=0xF5F5F5,
617 Yellow=0xFFFF00,
618 YellowGreen=0x9ACD32,
619
620 // LED RGB color that roughly approximates
621 // the color of incandescent fairy lights,
622 // assuming that you're using FastLED
623 // color correction on your LEDs (recommended).
624 FairyLight=0xFFE42D,
625
626 // If you are using no color correction, use this
627 FairyLightNCC=0xFF9D2A
628
630};
631
632
634FASTLED_FORCE_INLINE bool operator== (const CRGB& lhs, const CRGB& rhs)
635{
636 return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
637}
638
640FASTLED_FORCE_INLINE bool operator!= (const CRGB& lhs, const CRGB& rhs)
641{
642 return !(lhs == rhs);
643}
644
646FASTLED_FORCE_INLINE bool operator== (const CHSV& lhs, const CHSV& rhs)
647{
648 return (lhs.h == rhs.h) && (lhs.s == rhs.s) && (lhs.v == rhs.v);
649}
650
652FASTLED_FORCE_INLINE bool operator!= (const CHSV& lhs, const CHSV& rhs)
653{
654 return !(lhs == rhs);
655}
656
658FASTLED_FORCE_INLINE bool operator< (const CRGB& lhs, const CRGB& rhs)
659{
660 uint16_t sl, sr;
661 sl = lhs.r + lhs.g + lhs.b;
662 sr = rhs.r + rhs.g + rhs.b;
663 return sl < sr;
664}
665
667FASTLED_FORCE_INLINE bool operator> (const CRGB& lhs, const CRGB& rhs)
668{
669 uint16_t sl, sr;
670 sl = lhs.r + lhs.g + lhs.b;
671 sr = rhs.r + rhs.g + rhs.b;
672 return sl > sr;
673}
674
676FASTLED_FORCE_INLINE bool operator>= (const CRGB& lhs, const CRGB& rhs)
677{
678 uint16_t sl, sr;
679 sl = lhs.r + lhs.g + lhs.b;
680 sr = rhs.r + rhs.g + rhs.b;
681 return sl >= sr;
682}
683
685FASTLED_FORCE_INLINE bool operator<= (const CRGB& lhs, const CRGB& rhs)
686{
687 uint16_t sl, sr;
688 sl = lhs.r + lhs.g + lhs.b;
689 sr = rhs.r + rhs.g + rhs.b;
690 return sl <= sr;
691}
692
693
694
696FASTLED_FORCE_INLINE CRGB operator/( const CRGB& p1, uint8_t d)
697{
698 return CRGB( p1.r/d, p1.g/d, p1.b/d);
699}
700
701
703FASTLED_FORCE_INLINE CRGB operator&( const CRGB& p1, const CRGB& p2)
704{
705 return CRGB( p1.r < p2.r ? p1.r : p2.r,
706 p1.g < p2.g ? p1.g : p2.g,
707 p1.b < p2.b ? p1.b : p2.b);
708}
709
711FASTLED_FORCE_INLINE CRGB operator|( const CRGB& p1, const CRGB& p2)
712{
713 return CRGB( p1.r > p2.r ? p1.r : p2.r,
714 p1.g > p2.g ? p1.g : p2.g,
715 p1.b > p2.b ? p1.b : p2.b);
716}
717
719FASTLED_FORCE_INLINE CRGB operator+( const CRGB& p1, const CRGB& p2);
720
722FASTLED_FORCE_INLINE CRGB operator-( const CRGB& p1, const CRGB& p2);
723
725FASTLED_FORCE_INLINE CRGB operator*( const CRGB& p1, uint8_t d);
726
728FASTLED_FORCE_INLINE CRGB operator%( const CRGB& p1, uint8_t d);
729
730
731
732// Make compatible with std::ostream and other ostream-like objects
733FASTLED_DEFINE_OUTPUT_OPERATOR(CRGB) {
734 os <<("CRGB(");
735 os <<(static_cast<int>(obj.r));
736 os <<(", ");
737 os <<(static_cast<int>(obj.g));
738 os <<(", ");
739 os <<(static_cast<int>(obj.b));
740 os <<(")");
741 return os;
742}
743
744FASTLED_NAMESPACE_END
745
746
Contains definitions for color correction and temperature.
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:30
uint16_t fract16
ANSI: unsigned _Fract.
Definition types.h:40
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:75
void hsv2rgb_rainbow(const CHSV &hsv, CRGB &rgb)
Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.
Definition hsv2rgb.cpp:251
FASTLED_FORCE_INLINE CRGB()=default
Default constructor.
FASTLED_FORCE_INLINE uint8_t getLuma() const
Get the "luma" of a CRGB object.
Definition crgb.hpp:154
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:640
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:685
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:634
FASTLED_FORCE_INLINE CRGB operator/(const CRGB &p1, uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:696
uint8_t raw[3]
Access the red, green, and blue data as an array.
Definition crgb.h:60
uint8_t r
Red channel value.
Definition crgb.h:43
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:394
FASTLED_FORCE_INLINE CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:224
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:87
constexpr CRGB(ColorTemperature colorcode) noexcept
Allow construction from a ColorTemperature enum.
Definition crgb.h:117
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
Definition crgb.hpp:226
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:45
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:108
constexpr CRGB(uint32_t colorcode) noexcept
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
Definition crgb.h:96
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:189
FASTLED_FORCE_INLINE CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
Definition crgb.hpp:36
FASTLED_FORCE_INLINE CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
Definition crgb.h:148
FASTLED_FORCE_INLINE CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
Definition crgb.h:184
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:422
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:10
FASTLED_FORCE_INLINE CRGB(const CHSV &rhs)
Allow construction from a CHSV color.
Definition crgb.h:126
FASTLED_FORCE_INLINE CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
Definition crgb.h:160
FASTLED_FORCE_INLINE CRGB & operator--()
Subtract a constant of '1' from each channel, saturating at 0x00.
Definition crgb.hpp:94
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:210
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:658
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:178
uint8_t g
Green channel value.
Definition crgb.h:47
uint8_t red
Red channel value.
Definition crgb.h:44
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:711
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:703
FASTLED_FORCE_INLINE CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
Definition crgb.h:233
constexpr CRGB operator-() const
Invert each channel.
Definition crgb.h:338
FASTLED_FORCE_INLINE CRGB & operator+=(const CRGB &rhs)
Add one CRGB to another, saturating at 0xFF for each channel.
Definition crgb.hpp:20
FASTLED_FORCE_INLINE uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
Definition crgb.h:68
uint8_t blue
Blue channel value.
Definition crgb.h:52
FASTLED_FORCE_INLINE CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
Definition crgb.h:305
FASTLED_FORCE_INLINE uint8_t getAverageLight() const
Get the average of the R, G, and B values.
Definition crgb.hpp:165
FASTLED_FORCE_INLINE CRGB & addToRGB(uint8_t d)
Add a constant to each channel, saturating at 0xFF.
Definition crgb.hpp:28
FASTLED_FORCE_INLINE CRGB & subtractFromRGB(uint8_t d)
Subtract a constant from each channel, saturating at 0x00.
Definition crgb.hpp:59
constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
Allow construction from red, green, and blue.
Definition crgb.h:89
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:667
uint8_t b
Blue channel value.
Definition crgb.h:51
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:132
uint8_t green
Green channel value.
Definition crgb.h:48
FASTLED_FORCE_INLINE CRGB & operator*=(uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
Definition crgb.hpp:67
FASTLED_FORCE_INLINE CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
Definition crgb.h:169
FASTLED_FORCE_INLINE CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
Definition crgb.hpp:81
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:676
FASTLED_FORCE_INLINE void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
Definition crgb.h:367
constexpr CRGB(LEDColorCorrection colorcode) noexcept
Allow construction from a LEDColorCorrection enum.
Definition crgb.h:110
HTMLColorCode
Predefined RGB colors.
Definition crgb.h:470
FASTLED_FORCE_INLINE CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.hpp:148
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:218
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:202
FASTLED_FORCE_INLINE CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Definition crgb.h:287
@ DarkGray
Definition crgb.h:496
@ Sienna
Definition crgb.h:599
@ Plum
Definition crgb.h:588
@ GhostWhite
Definition crgb.h:522
@ Tan
Definition crgb.h:608
@ Gold
Definition crgb.h:523
@ DarkRed
Definition crgb.h:504
@ DarkSlateGray
Definition crgb.h:508
@ OldLace
Definition crgb.h:573
@ Aquamarine
Definition crgb.h:475
@ Violet
Definition crgb.h:613
@ Salmon
Definition crgb.h:595
@ Thistle
Definition crgb.h:610
@ Cornsilk
Definition crgb.h:490
@ MediumVioletRed
Definition crgb.h:566
@ Coral
Definition crgb.h:488
@ LightPink
Definition crgb.h:545
@ DarkGrey
Definition crgb.h:497
@ SlateGrey
Definition crgb.h:604
@ NavajoWhite
Definition crgb.h:571
@ PaleVioletRed
Definition crgb.h:582
@ HotPink
Definition crgb.h:530
@ BlanchedAlmond
Definition crgb.h:480
@ RosyBrown
Definition crgb.h:592
@ White
Definition crgb.h:615
@ Moccasin
Definition crgb.h:570
@ LightYellow
Definition crgb.h:552
@ Bisque
Definition crgb.h:478
@ DeepPink
Definition crgb.h:512
@ Wheat
Definition crgb.h:614
@ MediumOrchid
Definition crgb.h:560
@ Goldenrod
Definition crgb.h:524
@ Orange
Definition crgb.h:576
@ MediumSpringGreen
Definition crgb.h:564
@ Seashell
Definition crgb.h:598
@ DarkViolet
Definition crgb.h:511
@ Ivory
Definition crgb.h:533
@ Teal
Definition crgb.h:609
@ Gray
Definition crgb.h:525
@ MistyRose
Definition crgb.h:569
@ SlateBlue
Definition crgb.h:602
@ Silver
Definition crgb.h:600
@ Purple
Definition crgb.h:590
@ DarkKhaki
Definition crgb.h:499
@ SaddleBrown
Definition crgb.h:594
@ LemonChiffon
Definition crgb.h:538
@ Magenta
Definition crgb.h:556
@ Beige
Definition crgb.h:477
@ Crimson
Definition crgb.h:491
@ MediumAquamarine
Definition crgb.h:558
@ LawnGreen
Definition crgb.h:537
@ DodgerBlue
Definition crgb.h:516
@ Tomato
Definition crgb.h:611
@ Fuchsia
Definition crgb.h:520
@ Aqua
Definition crgb.h:474
@ Brown
Definition crgb.h:483
@ Pink
Definition crgb.h:586
@ Lavender
Definition crgb.h:535
@ YellowGreen
Definition crgb.h:618
@ DeepSkyBlue
Definition crgb.h:513
@ Turquoise
Definition crgb.h:612
@ SandyBrown
Definition crgb.h:596
@ MediumSlateBlue
Definition crgb.h:563
@ PeachPuff
Definition crgb.h:584
@ Orchid
Definition crgb.h:578
@ Green
Definition crgb.h:527
@ SteelBlue
Definition crgb.h:607
@ CornflowerBlue
Definition crgb.h:489
@ DarkSalmon
Definition crgb.h:505
@ SkyBlue
Definition crgb.h:601
@ LightSalmon
Definition crgb.h:546
@ RoyalBlue
Definition crgb.h:593
@ DarkSlateGrey
Definition crgb.h:509
@ Navy
Definition crgb.h:572
@ Lime
Definition crgb.h:553
@ LightCoral
Definition crgb.h:540
@ PaleTurquoise
Definition crgb.h:581
@ BurlyWood
Definition crgb.h:484
@ DarkTurquoise
Definition crgb.h:510
@ DarkMagenta
Definition crgb.h:500
@ LightSeaGreen
Definition crgb.h:547
@ MidnightBlue
Definition crgb.h:567
@ LightSlateGray
Definition crgb.h:549
@ Chocolate
Definition crgb.h:487
@ Linen
Definition crgb.h:555
@ SeaGreen
Definition crgb.h:597
@ Cyan
Definition crgb.h:492
@ AntiqueWhite
Definition crgb.h:473
@ LimeGreen
Definition crgb.h:554
@ MediumTurquoise
Definition crgb.h:565
@ LightGreen
Definition crgb.h:543
@ MediumSeaGreen
Definition crgb.h:562
@ PaleGreen
Definition crgb.h:580
@ FireBrick
Definition crgb.h:517
@ Amethyst
Definition crgb.h:472
@ LightSteelBlue
Definition crgb.h:551
@ LightGrey
Definition crgb.h:544
@ BlueViolet
Definition crgb.h:482
@ Indigo
Definition crgb.h:532
@ LightCyan
Definition crgb.h:541
@ Olive
Definition crgb.h:574
@ PapayaWhip
Definition crgb.h:583
@ Azure
Definition crgb.h:476
@ Blue
Definition crgb.h:481
@ DarkOrchid
Definition crgb.h:503
@ Red
Definition crgb.h:591
@ PowderBlue
Definition crgb.h:589
@ IndianRed
Definition crgb.h:531
@ FairyLight
Definition crgb.h:624
@ DarkGoldenrod
Definition crgb.h:495
@ LightSkyBlue
Definition crgb.h:548
@ DarkSlateBlue
Definition crgb.h:507
@ MediumBlue
Definition crgb.h:559
@ Black
Definition crgb.h:479
@ LavenderBlush
Definition crgb.h:536
@ DarkOrange
Definition crgb.h:502
@ CadetBlue
Definition crgb.h:485
@ SlateGray
Definition crgb.h:603
@ OliveDrab
Definition crgb.h:575
@ Plaid
Definition crgb.h:587
@ SpringGreen
Definition crgb.h:606
@ Honeydew
Definition crgb.h:529
@ Gainsboro
Definition crgb.h:521
@ MediumPurple
Definition crgb.h:561
@ Yellow
Definition crgb.h:617
@ DimGrey
Definition crgb.h:515
@ FairyLightNCC
Definition crgb.h:627
@ DarkOliveGreen
Definition crgb.h:501
@ LightGoldenrodYellow
Definition crgb.h:542
@ LightSlateGrey
Definition crgb.h:550
@ Peru
Definition crgb.h:585
@ AliceBlue
Definition crgb.h:471
@ PaleGoldenrod
Definition crgb.h:579
@ DarkSeaGreen
Definition crgb.h:506
@ LightBlue
Definition crgb.h:539
@ FloralWhite
Definition crgb.h:518
@ Chartreuse
Definition crgb.h:486
@ DimGray
Definition crgb.h:514
@ OrangeRed
Definition crgb.h:577
@ ForestGreen
Definition crgb.h:519
@ Khaki
Definition crgb.h:534
@ MintCream
Definition crgb.h:568
@ DarkCyan
Definition crgb.h:494
@ Snow
Definition crgb.h:605
@ DarkGreen
Definition crgb.h:498
@ GreenYellow
Definition crgb.h:528
@ WhiteSmoke
Definition crgb.h:616
@ DarkBlue
Definition crgb.h:493
@ Maroon
Definition crgb.h:557
@ Grey
Definition crgb.h:526
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:11
uint8_t v
Color value (brightness).
Definition chsv.h:33
uint8_t h
Color hue.
Definition chsv.h:19
uint8_t s
Color saturation.
Definition chsv.h:26
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39