FastLED 3.7.8
Loading...
Searching...
No Matches
crgb.h
1
2#pragma once
3
4#include <stdint.h>
5#include "chsv.h"
6#include "namespace.h"
7#include "color.h"
8#include "lib8tion/types.h"
9#include "force_inline.h"
10
11FASTLED_NAMESPACE_BEGIN
12
13struct CRGB;
14
18
21extern void hsv2rgb_rainbow( const CHSV& hsv, CRGB& rgb);
22
23
25struct CRGB {
26 union {
27 struct {
28 union {
29 uint8_t r;
30 uint8_t red;
31 };
32 union {
33 uint8_t g;
34 uint8_t green;
35 };
36 union {
37 uint8_t b;
38 uint8_t blue;
39 };
40 };
46 uint8_t raw[3];
47 };
48
52 FASTLED_FORCE_INLINE uint8_t& operator[] (uint8_t x)
53 {
54 return raw[x];
55 }
56
60 FASTLED_FORCE_INLINE const uint8_t& operator[] (uint8_t x) const
61 {
62 return raw[x];
63 }
64
67 FASTLED_FORCE_INLINE CRGB() = default;
68
73 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) __attribute__((always_inline))
74 : r(ir), g(ig), b(ib)
75 {
76 }
77
80 constexpr CRGB(uint32_t colorcode) __attribute__((always_inline))
81 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
82 {
83 }
84
87 constexpr CRGB(LEDColorCorrection colorcode) __attribute__((always_inline))
88 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
89 {
90 }
91
94 constexpr CRGB(ColorTemperature colorcode) __attribute__((always_inline))
95 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
96 {
97 }
98
100 FASTLED_FORCE_INLINE CRGB(const CRGB& rhs) = default;
101
103 FASTLED_FORCE_INLINE CRGB(const CHSV& rhs)
104 {
105 hsv2rgb_rainbow( rhs, *this);
106 }
107
109 FASTLED_FORCE_INLINE CRGB& operator= (const CRGB& rhs) = default;
110
113 FASTLED_FORCE_INLINE CRGB& operator= (const uint32_t colorcode)
114 {
115 r = (colorcode >> 16) & 0xFF;
116 g = (colorcode >> 8) & 0xFF;
117 b = (colorcode >> 0) & 0xFF;
118 return *this;
119 }
120
125 FASTLED_FORCE_INLINE CRGB& setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
126 {
127 r = nr;
128 g = ng;
129 b = nb;
130 return *this;
131 }
132
137 FASTLED_FORCE_INLINE CRGB& setHSV (uint8_t hue, uint8_t sat, uint8_t val)
138 {
139 hsv2rgb_rainbow( CHSV(hue, sat, val), *this);
140 return *this;
141 }
142
146 FASTLED_FORCE_INLINE CRGB& setHue (uint8_t hue)
147 {
148 hsv2rgb_rainbow( CHSV(hue, 255, 255), *this);
149 return *this;
150 }
151
153 FASTLED_FORCE_INLINE CRGB& operator= (const CHSV& rhs)
154 {
155 hsv2rgb_rainbow( rhs, *this);
156 return *this;
157 }
158
161 FASTLED_FORCE_INLINE CRGB& setColorCode (uint32_t colorcode)
162 {
163 r = (colorcode >> 16) & 0xFF;
164 g = (colorcode >> 8) & 0xFF;
165 b = (colorcode >> 0) & 0xFF;
166 return *this;
167 }
168
169
171 FASTLED_FORCE_INLINE CRGB& operator+= (const CRGB& rhs);
172
177 FASTLED_FORCE_INLINE CRGB& addToRGB (uint8_t d);
178
180 FASTLED_FORCE_INLINE CRGB& operator-= (const CRGB& rhs);
181
186 FASTLED_FORCE_INLINE CRGB& subtractFromRGB(uint8_t d );
187
189 FASTLED_FORCE_INLINE CRGB& operator-- ()
190 {
192 return *this;
193 }
194
196 FASTLED_FORCE_INLINE CRGB operator-- (int )
197 {
198 CRGB retval(*this);
199 --(*this);
200 return retval;
201 }
202
204 FASTLED_FORCE_INLINE CRGB& operator++ ()
205 {
206 addToRGB(1);
207 return *this;
208 }
209
211 FASTLED_FORCE_INLINE CRGB operator++ (int )
212 {
213 CRGB retval(*this);
214 ++(*this);
215 return retval;
216 }
217
219 FASTLED_FORCE_INLINE CRGB& operator/= (uint8_t d )
220 {
221 r /= d;
222 g /= d;
223 b /= d;
224 return *this;
225 }
226
228 FASTLED_FORCE_INLINE CRGB& operator>>= (uint8_t d)
229 {
230 r >>= d;
231 g >>= d;
232 b >>= d;
233 return *this;
234 }
235
238 FASTLED_FORCE_INLINE CRGB& operator*= (uint8_t d);
239
246 FASTLED_FORCE_INLINE CRGB& nscale8_video (uint8_t scaledown);
247
250 FASTLED_FORCE_INLINE CRGB& operator%= (uint8_t scaledown);
251
254 FASTLED_FORCE_INLINE CRGB& fadeLightBy (uint8_t fadefactor );
255
260 FASTLED_FORCE_INLINE CRGB& nscale8 (uint8_t scaledown );
261
266 FASTLED_FORCE_INLINE CRGB& nscale8 (const CRGB & scaledown );
267
269 FASTLED_FORCE_INLINE CRGB scale8 (uint8_t scaledown ) const;
270
272 FASTLED_FORCE_INLINE CRGB scale8 (const CRGB & scaledown ) const;
273
276 FASTLED_FORCE_INLINE CRGB& fadeToBlackBy (uint8_t fadefactor );
277
279 FASTLED_FORCE_INLINE CRGB& operator|= (const CRGB& rhs )
280 {
281 if( rhs.r > r) r = rhs.r;
282 if( rhs.g > g) g = rhs.g;
283 if( rhs.b > b) b = rhs.b;
284 return *this;
285 }
286
288 FASTLED_FORCE_INLINE CRGB& operator|= (uint8_t d )
289 {
290 if( d > r) r = d;
291 if( d > g) g = d;
292 if( d > b) b = d;
293 return *this;
294 }
295
297 FASTLED_FORCE_INLINE CRGB& operator&= (const CRGB& rhs )
298 {
299 if( rhs.r < r) r = rhs.r;
300 if( rhs.g < g) g = rhs.g;
301 if( rhs.b < b) b = rhs.b;
302 return *this;
303 }
304
306 FASTLED_FORCE_INLINE CRGB& operator&= (uint8_t d )
307 {
308 if( d < r) r = d;
309 if( d < g) g = d;
310 if( d < b) b = d;
311 return *this;
312 }
313
315 FASTLED_FORCE_INLINE explicit operator bool() const
316 {
317 return r || g || b;
318 }
319
321 FASTLED_FORCE_INLINE explicit operator uint32_t() const
322 {
323 return uint32_t(0xff000000) |
324 (uint32_t{r} << 16) |
325 (uint32_t{g} << 8) |
326 uint32_t{b};
327 }
328
330 FASTLED_FORCE_INLINE CRGB operator- () const
331 {
332 CRGB retval;
333 retval.r = 255 - r;
334 retval.g = 255 - g;
335 retval.b = 255 - b;
336 return retval;
337 }
338
339#if (defined SmartMatrix_h || defined SmartMatrix3_h)
342 operator rgb24() const {
343 rgb24 ret;
344 ret.red = r;
345 ret.green = g;
346 ret.blue = b;
347 return ret;
348 }
349#endif
350
353 FASTLED_FORCE_INLINE uint8_t getLuma() const;
354
356 FASTLED_FORCE_INLINE uint8_t getAverageLight() const;
357
363 FASTLED_FORCE_INLINE void maximizeBrightness( uint8_t limit = 255 ) {
364 uint8_t max = red;
365 if( green > max) max = green;
366 if( blue > max) max = blue;
367
368 // stop div/0 when color is black
369 if(max > 0) {
370 uint16_t factor = ((uint16_t)(limit) * 256) / max;
371 red = (red * factor) / 256;
372 green = (green * factor) / 256;
373 blue = (blue * factor) / 256;
374 }
375 }
376
378 FASTLED_FORCE_INLINE CRGB lerp8( const CRGB& other, fract8 frac) const;
379
381 FASTLED_FORCE_INLINE CRGB lerp16( const CRGB& other, fract16 frac) const;
383 FASTLED_FORCE_INLINE uint8_t getParity()
384 {
385 uint8_t sum = r + g + b;
386 return (sum & 0x01);
387 }
388
411 FASTLED_FORCE_INLINE void setParity( uint8_t parity)
412 {
413 uint8_t curparity = getParity();
414
415 if( parity == curparity) return;
416
417 if( parity ) {
418 // going 'up'
419 if( (b > 0) && (b < 255)) {
420 if( r == g && g == b) {
421 ++r;
422 ++g;
423 }
424 ++b;
425 } else if( (r > 0) && (r < 255)) {
426 ++r;
427 } else if( (g > 0) && (g < 255)) {
428 ++g;
429 } else {
430 if( r == g && g == b) {
431 r ^= 0x01;
432 g ^= 0x01;
433 }
434 b ^= 0x01;
435 }
436 } else {
437 // going 'down'
438 if( b > 1) {
439 if( r == g && g == b) {
440 --r;
441 --g;
442 }
443 --b;
444 } else if( g > 1) {
445 --g;
446 } else if( r > 1) {
447 --r;
448 } else {
449 if( r == g && g == b) {
450 r ^= 0x01;
451 g ^= 0x01;
452 }
453 b ^= 0x01;
454 }
455 }
456 }
457
459 typedef enum {
460 AliceBlue=0xF0F8FF,
461 Amethyst=0x9966CC,
462 AntiqueWhite=0xFAEBD7,
463 Aqua=0x00FFFF,
464 Aquamarine=0x7FFFD4,
465 Azure=0xF0FFFF,
466 Beige=0xF5F5DC,
467 Bisque=0xFFE4C4,
468 Black=0x000000,
469 BlanchedAlmond=0xFFEBCD,
470 Blue=0x0000FF,
471 BlueViolet=0x8A2BE2,
472 Brown=0xA52A2A,
473 BurlyWood=0xDEB887,
474 CadetBlue=0x5F9EA0,
475 Chartreuse=0x7FFF00,
476 Chocolate=0xD2691E,
477 Coral=0xFF7F50,
478 CornflowerBlue=0x6495ED,
479 Cornsilk=0xFFF8DC,
480 Crimson=0xDC143C,
481 Cyan=0x00FFFF,
482 DarkBlue=0x00008B,
483 DarkCyan=0x008B8B,
484 DarkGoldenrod=0xB8860B,
485 DarkGray=0xA9A9A9,
486 DarkGrey=0xA9A9A9,
487 DarkGreen=0x006400,
488 DarkKhaki=0xBDB76B,
489 DarkMagenta=0x8B008B,
490 DarkOliveGreen=0x556B2F,
491 DarkOrange=0xFF8C00,
492 DarkOrchid=0x9932CC,
493 DarkRed=0x8B0000,
494 DarkSalmon=0xE9967A,
495 DarkSeaGreen=0x8FBC8F,
496 DarkSlateBlue=0x483D8B,
497 DarkSlateGray=0x2F4F4F,
498 DarkSlateGrey=0x2F4F4F,
499 DarkTurquoise=0x00CED1,
500 DarkViolet=0x9400D3,
501 DeepPink=0xFF1493,
502 DeepSkyBlue=0x00BFFF,
503 DimGray=0x696969,
504 DimGrey=0x696969,
505 DodgerBlue=0x1E90FF,
506 FireBrick=0xB22222,
507 FloralWhite=0xFFFAF0,
508 ForestGreen=0x228B22,
509 Fuchsia=0xFF00FF,
510 Gainsboro=0xDCDCDC,
511 GhostWhite=0xF8F8FF,
512 Gold=0xFFD700,
513 Goldenrod=0xDAA520,
514 Gray=0x808080,
515 Grey=0x808080,
516 Green=0x008000,
517 GreenYellow=0xADFF2F,
518 Honeydew=0xF0FFF0,
519 HotPink=0xFF69B4,
520 IndianRed=0xCD5C5C,
521 Indigo=0x4B0082,
522 Ivory=0xFFFFF0,
523 Khaki=0xF0E68C,
524 Lavender=0xE6E6FA,
525 LavenderBlush=0xFFF0F5,
526 LawnGreen=0x7CFC00,
527 LemonChiffon=0xFFFACD,
528 LightBlue=0xADD8E6,
529 LightCoral=0xF08080,
530 LightCyan=0xE0FFFF,
532 LightGreen=0x90EE90,
533 LightGrey=0xD3D3D3,
534 LightPink=0xFFB6C1,
535 LightSalmon=0xFFA07A,
536 LightSeaGreen=0x20B2AA,
537 LightSkyBlue=0x87CEFA,
538 LightSlateGray=0x778899,
539 LightSlateGrey=0x778899,
540 LightSteelBlue=0xB0C4DE,
541 LightYellow=0xFFFFE0,
542 Lime=0x00FF00,
543 LimeGreen=0x32CD32,
544 Linen=0xFAF0E6,
545 Magenta=0xFF00FF,
546 Maroon=0x800000,
548 MediumBlue=0x0000CD,
549 MediumOrchid=0xBA55D3,
550 MediumPurple=0x9370DB,
551 MediumSeaGreen=0x3CB371,
556 MidnightBlue=0x191970,
557 MintCream=0xF5FFFA,
558 MistyRose=0xFFE4E1,
559 Moccasin=0xFFE4B5,
560 NavajoWhite=0xFFDEAD,
561 Navy=0x000080,
562 OldLace=0xFDF5E6,
563 Olive=0x808000,
564 OliveDrab=0x6B8E23,
565 Orange=0xFFA500,
566 OrangeRed=0xFF4500,
567 Orchid=0xDA70D6,
568 PaleGoldenrod=0xEEE8AA,
569 PaleGreen=0x98FB98,
570 PaleTurquoise=0xAFEEEE,
571 PaleVioletRed=0xDB7093,
572 PapayaWhip=0xFFEFD5,
573 PeachPuff=0xFFDAB9,
574 Peru=0xCD853F,
575 Pink=0xFFC0CB,
576 Plaid=0xCC5533,
577 Plum=0xDDA0DD,
578 PowderBlue=0xB0E0E6,
579 Purple=0x800080,
580 Red=0xFF0000,
581 RosyBrown=0xBC8F8F,
582 RoyalBlue=0x4169E1,
583 SaddleBrown=0x8B4513,
584 Salmon=0xFA8072,
585 SandyBrown=0xF4A460,
586 SeaGreen=0x2E8B57,
587 Seashell=0xFFF5EE,
588 Sienna=0xA0522D,
589 Silver=0xC0C0C0,
590 SkyBlue=0x87CEEB,
591 SlateBlue=0x6A5ACD,
592 SlateGray=0x708090,
593 SlateGrey=0x708090,
594 Snow=0xFFFAFA,
595 SpringGreen=0x00FF7F,
596 SteelBlue=0x4682B4,
597 Tan=0xD2B48C,
598 Teal=0x008080,
599 Thistle=0xD8BFD8,
600 Tomato=0xFF6347,
601 Turquoise=0x40E0D0,
602 Violet=0xEE82EE,
603 Wheat=0xF5DEB3,
604 White=0xFFFFFF,
605 WhiteSmoke=0xF5F5F5,
606 Yellow=0xFFFF00,
607 YellowGreen=0x9ACD32,
608
609 // LED RGB color that roughly approximates
610 // the color of incandescent fairy lights,
611 // assuming that you're using FastLED
612 // color correction on your LEDs (recommended).
613 FairyLight=0xFFE42D,
614
615 // If you are using no color correction, use this
616 FairyLightNCC=0xFF9D2A
617
619};
620
621
623FASTLED_FORCE_INLINE bool operator== (const CRGB& lhs, const CRGB& rhs)
624{
625 return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
626}
627
629FASTLED_FORCE_INLINE bool operator!= (const CRGB& lhs, const CRGB& rhs)
630{
631 return !(lhs == rhs);
632}
633
635FASTLED_FORCE_INLINE bool operator== (const CHSV& lhs, const CHSV& rhs)
636{
637 return (lhs.h == rhs.h) && (lhs.s == rhs.s) && (lhs.v == rhs.v);
638}
639
641FASTLED_FORCE_INLINE bool operator!= (const CHSV& lhs, const CHSV& rhs)
642{
643 return !(lhs == rhs);
644}
645
647FASTLED_FORCE_INLINE bool operator< (const CRGB& lhs, const CRGB& rhs)
648{
649 uint16_t sl, sr;
650 sl = lhs.r + lhs.g + lhs.b;
651 sr = rhs.r + rhs.g + rhs.b;
652 return sl < sr;
653}
654
656FASTLED_FORCE_INLINE bool operator> (const CRGB& lhs, const CRGB& rhs)
657{
658 uint16_t sl, sr;
659 sl = lhs.r + lhs.g + lhs.b;
660 sr = rhs.r + rhs.g + rhs.b;
661 return sl > sr;
662}
663
665FASTLED_FORCE_INLINE bool operator>= (const CRGB& lhs, const CRGB& rhs)
666{
667 uint16_t sl, sr;
668 sl = lhs.r + lhs.g + lhs.b;
669 sr = rhs.r + rhs.g + rhs.b;
670 return sl >= sr;
671}
672
674FASTLED_FORCE_INLINE bool operator<= (const CRGB& lhs, const CRGB& rhs)
675{
676 uint16_t sl, sr;
677 sl = lhs.r + lhs.g + lhs.b;
678 sr = rhs.r + rhs.g + rhs.b;
679 return sl <= sr;
680}
681
682
683
685FASTLED_FORCE_INLINE CRGB operator/( const CRGB& p1, uint8_t d)
686{
687 return CRGB( p1.r/d, p1.g/d, p1.b/d);
688}
689
690
692FASTLED_FORCE_INLINE CRGB operator&( const CRGB& p1, const CRGB& p2)
693{
694 return CRGB( p1.r < p2.r ? p1.r : p2.r,
695 p1.g < p2.g ? p1.g : p2.g,
696 p1.b < p2.b ? p1.b : p2.b);
697}
698
700FASTLED_FORCE_INLINE CRGB operator|( const CRGB& p1, const CRGB& p2)
701{
702 return CRGB( p1.r > p2.r ? p1.r : p2.r,
703 p1.g > p2.g ? p1.g : p2.g,
704 p1.b > p2.b ? p1.b : p2.b);
705}
706
708FASTLED_FORCE_INLINE CRGB operator+( const CRGB& p1, const CRGB& p2);
709
711FASTLED_FORCE_INLINE CRGB operator-( const CRGB& p1, const CRGB& p2);
712
714FASTLED_FORCE_INLINE CRGB operator*( const CRGB& p1, uint8_t d);
715
717FASTLED_FORCE_INLINE CRGB operator%( const CRGB& p1, uint8_t d);
718
719FASTLED_NAMESPACE_END
Contains definitions for color correction and temperature.
ColorTemperature
Color temperature values.
Definition color.h:47
LEDColorCorrection
Color correction starting points.
Definition color.h:16
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:54
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:108
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:629
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:674
constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib)
Allow construction from red, green, and blue.
Definition crgb.h:73
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:623
FASTLED_FORCE_INLINE CRGB operator/(const CRGB &p1, uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:685
uint8_t raw[3]
Access the red, green, and blue data as an array.
Definition crgb.h:46
uint8_t r
Red channel value.
Definition crgb.h:29
constexpr CRGB(uint32_t colorcode)
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
Definition crgb.h:80
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:383
FASTLED_FORCE_INLINE CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:219
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:66
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
Definition crgb.hpp:180
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.h:204
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:72
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:143
FASTLED_FORCE_INLINE CRGB operator-() const
Invert each channel.
Definition crgb.h:330
FASTLED_FORCE_INLINE CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
Definition crgb.hpp:30
FASTLED_FORCE_INLINE CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
Definition crgb.h:125
FASTLED_FORCE_INLINE CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
Definition crgb.h:161
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:411
FASTLED_FORCE_INLINE CRGB(const CHSV &rhs)
Allow construction from a CHSV color.
Definition crgb.h:103
FASTLED_FORCE_INLINE CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
Definition crgb.h:137
FASTLED_FORCE_INLINE CRGB & operator--()
Subtract a constant of '1' from each channel, saturating at 0x00.
Definition crgb.h:189
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:164
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:647
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:132
uint8_t g
Green channel value.
Definition crgb.h:33
uint8_t red
Red channel value.
Definition crgb.h:30
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:700
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:692
FASTLED_FORCE_INLINE CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
Definition crgb.h:228
FASTLED_FORCE_INLINE CRGB & operator+=(const CRGB &rhs)
Add one CRGB to another, saturating at 0xFF for each channel.
Definition crgb.hpp:14
FASTLED_FORCE_INLINE uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
Definition crgb.h:52
uint8_t blue
Blue channel value.
Definition crgb.h:38
FASTLED_FORCE_INLINE CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
Definition crgb.h:297
FASTLED_FORCE_INLINE uint8_t getAverageLight() const
Get the average of the R, G, and B values.
Definition crgb.hpp:119
FASTLED_FORCE_INLINE CRGB & addToRGB(uint8_t d)
Add a constant to each channel, saturating at 0xFF.
Definition crgb.hpp:22
FASTLED_FORCE_INLINE CRGB & subtractFromRGB(uint8_t d)
Subtract a constant from each channel, saturating at 0x00.
Definition crgb.hpp:38
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:656
uint8_t b
Blue channel value.
Definition crgb.h:37
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:86
uint8_t green
Green channel value.
Definition crgb.h:34
FASTLED_FORCE_INLINE CRGB & operator*=(uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
Definition crgb.hpp:46
constexpr CRGB(LEDColorCorrection colorcode)
Allow construction from a LEDColorCorrection enum.
Definition crgb.h:87
FASTLED_FORCE_INLINE CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
Definition crgb.h:146
FASTLED_FORCE_INLINE CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
Definition crgb.hpp:60
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:665
constexpr CRGB(ColorTemperature colorcode)
Allow construction from a ColorTemperature enum.
Definition crgb.h:94
FASTLED_FORCE_INLINE void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
Definition crgb.h:363
HTMLColorCode
Predefined RGB colors.
Definition crgb.h:459
FASTLED_FORCE_INLINE CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.hpp:102
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:172
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:156
FASTLED_FORCE_INLINE CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Definition crgb.h:279
@ DarkGray
Definition crgb.h:485
@ Sienna
Definition crgb.h:588
@ Plum
Definition crgb.h:577
@ GhostWhite
Definition crgb.h:511
@ Tan
Definition crgb.h:597
@ Gold
Definition crgb.h:512
@ DarkRed
Definition crgb.h:493
@ DarkSlateGray
Definition crgb.h:497
@ OldLace
Definition crgb.h:562
@ Aquamarine
Definition crgb.h:464
@ Violet
Definition crgb.h:602
@ Salmon
Definition crgb.h:584
@ Thistle
Definition crgb.h:599
@ Cornsilk
Definition crgb.h:479
@ MediumVioletRed
Definition crgb.h:555
@ Coral
Definition crgb.h:477
@ LightPink
Definition crgb.h:534
@ DarkGrey
Definition crgb.h:486
@ SlateGrey
Definition crgb.h:593
@ NavajoWhite
Definition crgb.h:560
@ PaleVioletRed
Definition crgb.h:571
@ HotPink
Definition crgb.h:519
@ BlanchedAlmond
Definition crgb.h:469
@ RosyBrown
Definition crgb.h:581
@ White
Definition crgb.h:604
@ Moccasin
Definition crgb.h:559
@ LightYellow
Definition crgb.h:541
@ Bisque
Definition crgb.h:467
@ DeepPink
Definition crgb.h:501
@ Wheat
Definition crgb.h:603
@ MediumOrchid
Definition crgb.h:549
@ Goldenrod
Definition crgb.h:513
@ Orange
Definition crgb.h:565
@ MediumSpringGreen
Definition crgb.h:553
@ Seashell
Definition crgb.h:587
@ DarkViolet
Definition crgb.h:500
@ Ivory
Definition crgb.h:522
@ Teal
Definition crgb.h:598
@ Gray
Definition crgb.h:514
@ MistyRose
Definition crgb.h:558
@ SlateBlue
Definition crgb.h:591
@ Silver
Definition crgb.h:589
@ Purple
Definition crgb.h:579
@ DarkKhaki
Definition crgb.h:488
@ SaddleBrown
Definition crgb.h:583
@ LemonChiffon
Definition crgb.h:527
@ Magenta
Definition crgb.h:545
@ Beige
Definition crgb.h:466
@ Crimson
Definition crgb.h:480
@ MediumAquamarine
Definition crgb.h:547
@ LawnGreen
Definition crgb.h:526
@ DodgerBlue
Definition crgb.h:505
@ Tomato
Definition crgb.h:600
@ Fuchsia
Definition crgb.h:509
@ Aqua
Definition crgb.h:463
@ Brown
Definition crgb.h:472
@ Pink
Definition crgb.h:575
@ Lavender
Definition crgb.h:524
@ YellowGreen
Definition crgb.h:607
@ DeepSkyBlue
Definition crgb.h:502
@ Turquoise
Definition crgb.h:601
@ SandyBrown
Definition crgb.h:585
@ MediumSlateBlue
Definition crgb.h:552
@ PeachPuff
Definition crgb.h:573
@ Orchid
Definition crgb.h:567
@ Green
Definition crgb.h:516
@ SteelBlue
Definition crgb.h:596
@ CornflowerBlue
Definition crgb.h:478
@ DarkSalmon
Definition crgb.h:494
@ SkyBlue
Definition crgb.h:590
@ LightSalmon
Definition crgb.h:535
@ RoyalBlue
Definition crgb.h:582
@ DarkSlateGrey
Definition crgb.h:498
@ Navy
Definition crgb.h:561
@ Lime
Definition crgb.h:542
@ LightCoral
Definition crgb.h:529
@ PaleTurquoise
Definition crgb.h:570
@ BurlyWood
Definition crgb.h:473
@ DarkTurquoise
Definition crgb.h:499
@ DarkMagenta
Definition crgb.h:489
@ LightSeaGreen
Definition crgb.h:536
@ MidnightBlue
Definition crgb.h:556
@ LightSlateGray
Definition crgb.h:538
@ Chocolate
Definition crgb.h:476
@ Linen
Definition crgb.h:544
@ SeaGreen
Definition crgb.h:586
@ Cyan
Definition crgb.h:481
@ AntiqueWhite
Definition crgb.h:462
@ LimeGreen
Definition crgb.h:543
@ MediumTurquoise
Definition crgb.h:554
@ LightGreen
Definition crgb.h:532
@ MediumSeaGreen
Definition crgb.h:551
@ PaleGreen
Definition crgb.h:569
@ FireBrick
Definition crgb.h:506
@ Amethyst
Definition crgb.h:461
@ LightSteelBlue
Definition crgb.h:540
@ LightGrey
Definition crgb.h:533
@ BlueViolet
Definition crgb.h:471
@ Indigo
Definition crgb.h:521
@ LightCyan
Definition crgb.h:530
@ Olive
Definition crgb.h:563
@ PapayaWhip
Definition crgb.h:572
@ Azure
Definition crgb.h:465
@ Blue
Definition crgb.h:470
@ DarkOrchid
Definition crgb.h:492
@ Red
Definition crgb.h:580
@ PowderBlue
Definition crgb.h:578
@ IndianRed
Definition crgb.h:520
@ FairyLight
Definition crgb.h:613
@ DarkGoldenrod
Definition crgb.h:484
@ LightSkyBlue
Definition crgb.h:537
@ DarkSlateBlue
Definition crgb.h:496
@ MediumBlue
Definition crgb.h:548
@ Black
Definition crgb.h:468
@ LavenderBlush
Definition crgb.h:525
@ DarkOrange
Definition crgb.h:491
@ CadetBlue
Definition crgb.h:474
@ SlateGray
Definition crgb.h:592
@ OliveDrab
Definition crgb.h:564
@ Plaid
Definition crgb.h:576
@ SpringGreen
Definition crgb.h:595
@ Honeydew
Definition crgb.h:518
@ Gainsboro
Definition crgb.h:510
@ MediumPurple
Definition crgb.h:550
@ Yellow
Definition crgb.h:606
@ DimGrey
Definition crgb.h:504
@ FairyLightNCC
Definition crgb.h:616
@ DarkOliveGreen
Definition crgb.h:490
@ LightGoldenrodYellow
Definition crgb.h:531
@ LightSlateGrey
Definition crgb.h:539
@ Peru
Definition crgb.h:574
@ AliceBlue
Definition crgb.h:460
@ PaleGoldenrod
Definition crgb.h:568
@ DarkSeaGreen
Definition crgb.h:495
@ LightBlue
Definition crgb.h:528
@ FloralWhite
Definition crgb.h:507
@ Chartreuse
Definition crgb.h:475
@ DimGray
Definition crgb.h:503
@ OrangeRed
Definition crgb.h:566
@ ForestGreen
Definition crgb.h:508
@ Khaki
Definition crgb.h:523
@ MintCream
Definition crgb.h:557
@ DarkCyan
Definition crgb.h:483
@ Snow
Definition crgb.h:594
@ DarkGreen
Definition crgb.h:487
@ GreenYellow
Definition crgb.h:517
@ WhiteSmoke
Definition crgb.h:605
@ DarkBlue
Definition crgb.h:482
@ Maroon
Definition crgb.h:546
@ Grey
Definition crgb.h:515
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:25