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;
18class XYMap;
19}
20
22
23// Whether to allow HD_COLOR_MIXING
24#ifndef FASTLED_HD_COLOR_MIXING
25#ifdef __AVR__
26// Saves some memory on these constrained devices.
27#define FASTLED_HD_COLOR_MIXING 0
28#else
29#define FASTLED_HD_COLOR_MIXING 1
30#endif // __AVR__
31#endif // FASTLED_HD_COLOR_MIXING
32
33
34struct CRGB;
35
39
51void hsv2rgb_rainbow( const struct CHSV& hsv, struct CRGB& rgb);
52
53
55struct CRGB {
56 union {
57 struct {
58 union {
59 uint8_t r;
60 uint8_t red;
61 };
62 union {
63 uint8_t g;
64 uint8_t green;
65 };
66 union {
67 uint8_t b;
68 uint8_t blue;
69 };
70 };
71
76 uint8_t raw[3];
77 };
78
79 static CRGB blend(const CRGB& p1, const CRGB& p2, fract8 amountOfP2);
80 static CRGB blendAlphaMaxChannel(const CRGB& upper, const CRGB& lower);
81
83 static void downscale(const CRGB* src, const fl::XYMap& srcXY, CRGB* dst, const fl::XYMap& dstXY);
84 static void upscale(const CRGB* src, const fl::XYMap& srcXY, CRGB* dst, const fl::XYMap& dstXY);
85
90 {
91 return raw[x];
92 }
93
97 FASTLED_FORCE_INLINE const uint8_t& operator[] (uint8_t x) const
98 {
99 return raw[x];
100 }
101
105
110 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
111 : r(ir), g(ig), b(ib)
112 {
113 }
114
117 constexpr CRGB(uint32_t colorcode) noexcept
118 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
119 {
120 }
121
122 constexpr uint32_t as_uint32_t() const noexcept {
123 return uint32_t(0xff000000) |
124 (uint32_t{r} << 16) |
125 (uint32_t{g} << 8) |
126 uint32_t{b};
127 }
128
131 constexpr CRGB(LEDColorCorrection colorcode) noexcept
132 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
133 {
134 }
135
138 constexpr CRGB(ColorTemperature colorcode) noexcept
139 : r((colorcode >> 16) & 0xFF), g((colorcode >> 8) & 0xFF), b((colorcode >> 0) & 0xFF)
140 {
141 }
142
144 FASTLED_FORCE_INLINE CRGB(const CRGB& rhs) = default;
145
148 {
149 hsv2rgb_rainbow( rhs, *this);
150 }
151
153 FASTLED_FORCE_INLINE CRGB& operator= (const CRGB& rhs) = default;
154
157 FASTLED_FORCE_INLINE CRGB& operator= (const uint32_t colorcode)
158 {
159 r = (colorcode >> 16) & 0xFF;
160 g = (colorcode >> 8) & 0xFF;
161 b = (colorcode >> 0) & 0xFF;
162 return *this;
163 }
164
169 FASTLED_FORCE_INLINE CRGB& setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
170 {
171 r = nr;
172 g = ng;
173 b = nb;
174 return *this;
175 }
176
181 FASTLED_FORCE_INLINE CRGB& setHSV (uint8_t hue, uint8_t sat, uint8_t val)
182 {
183 hsv2rgb_rainbow( CHSV(hue, sat, val), *this);
184 return *this;
185 }
186
191 {
192 hsv2rgb_rainbow( CHSV(hue, 255, 255), *this);
193 return *this;
194 }
195
198 {
199 hsv2rgb_rainbow( rhs, *this);
200 return *this;
201 }
202
206 {
207 r = (colorcode >> 16) & 0xFF;
208 g = (colorcode >> 8) & 0xFF;
209 b = (colorcode >> 0) & 0xFF;
210 return *this;
211 }
212
213
215 CRGB& operator+= (const CRGB& rhs);
216
222
225
231
234
237
240
243
246 {
247 r /= d;
248 g /= d;
249 b /= d;
250 return *this;
251 }
252
255 {
256 r >>= d;
257 g >>= d;
258 b >>= d;
259 return *this;
260 }
261
265
272 FASTLED_FORCE_INLINE CRGB& nscale8_video (uint8_t scaledown);
273
276 FASTLED_FORCE_INLINE CRGB& operator%= (uint8_t scaledown);
277
280 FASTLED_FORCE_INLINE CRGB& fadeLightBy (uint8_t fadefactor );
281
286 CRGB& nscale8 (uint8_t scaledown );
287
292 FASTLED_FORCE_INLINE CRGB& nscale8 (const CRGB & scaledown );
293
294 constexpr CRGB nscale8_constexpr (const CRGB scaledown ) const;
295
296
298 FASTLED_FORCE_INLINE CRGB scale8 (uint8_t scaledown ) const;
299
301 FASTLED_FORCE_INLINE CRGB scale8 (const CRGB & scaledown ) const;
302
305 CRGB& fadeToBlackBy (uint8_t fadefactor );
306
309 {
310 if( rhs.r > r) r = rhs.r;
311 if( rhs.g > g) g = rhs.g;
312 if( rhs.b > b) b = rhs.b;
313 return *this;
314 }
315
318 {
319 if( d > r) r = d;
320 if( d > g) g = d;
321 if( d > b) b = d;
322 return *this;
323 }
324
327 {
328 if( rhs.r < r) r = rhs.r;
329 if( rhs.g < g) g = rhs.g;
330 if( rhs.b < b) b = rhs.b;
331 return *this;
332 }
333
336 {
337 if( d < r) r = d;
338 if( d < g) g = d;
339 if( d < b) b = d;
340 return *this;
341 }
342
344 constexpr explicit operator bool() const
345 {
346 return r || g || b;
347 }
348
350 constexpr explicit operator uint32_t() const
351 {
352 return uint32_t(0xff000000) |
353 (uint32_t{r} << 16) |
354 (uint32_t{g} << 8) |
355 uint32_t{b};
356 }
357
359 constexpr CRGB operator-() const
360 {
361 return CRGB(255 - r, 255 - g, 255 - b);
362 }
363
364#if (defined SmartMatrix_h || defined SmartMatrix3_h)
367 operator rgb24() const {
368 rgb24 ret;
369 ret.red = r;
370 ret.green = g;
371 ret.blue = b;
372 return ret;
373 }
374#endif
375
376 fl::Str toString() const;
377
380 uint8_t getLuma() const;
381
382
383
386
392 FASTLED_FORCE_INLINE void maximizeBrightness( uint8_t limit = 255 ) {
393 uint8_t max = red;
394 if( green > max) max = green;
395 if( blue > max) max = blue;
396
397 // stop div/0 when color is black
398 if(max > 0) {
399 uint16_t factor = ((uint16_t)(limit) * 256) / max;
400 red = (red * factor) / 256;
401 green = (green * factor) / 256;
402 blue = (blue * factor) / 256;
403 }
404 }
405
411 static CRGB computeAdjustment(uint8_t scale, const CRGB & colorCorrection, const CRGB & colorTemperature);
412
414 CRGB lerp8( const CRGB& other, fract8 amountOf2) const;
415
417 FASTLED_FORCE_INLINE CRGB lerp16( const CRGB& other, fract16 frac) const;
420 {
421 uint8_t sum = r + g + b;
422 return (sum & 0x01);
423 }
424
447 FASTLED_FORCE_INLINE void setParity( uint8_t parity)
448 {
449 uint8_t curparity = getParity();
450
451 if( parity == curparity) return;
452
453 if( parity ) {
454 // going 'up'
455 if( (b > 0) && (b < 255)) {
456 if( r == g && g == b) {
457 ++r;
458 ++g;
459 }
460 ++b;
461 } else if( (r > 0) && (r < 255)) {
462 ++r;
463 } else if( (g > 0) && (g < 255)) {
464 ++g;
465 } else {
466 if( r == g && g == b) {
467 r ^= 0x01;
468 g ^= 0x01;
469 }
470 b ^= 0x01;
471 }
472 } else {
473 // going 'down'
474 if( b > 1) {
475 if( r == g && g == b) {
476 --r;
477 --g;
478 }
479 --b;
480 } else if( g > 1) {
481 --g;
482 } else if( r > 1) {
483 --r;
484 } else {
485 if( r == g && g == b) {
486 r ^= 0x01;
487 g ^= 0x01;
488 }
489 b ^= 0x01;
490 }
491 }
492 }
493
495 typedef enum {
496 AliceBlue=0xF0F8FF,
497 Amethyst=0x9966CC,
498 AntiqueWhite=0xFAEBD7,
499 Aqua=0x00FFFF,
500 Aquamarine=0x7FFFD4,
501 Azure=0xF0FFFF,
502 Beige=0xF5F5DC,
503 Bisque=0xFFE4C4,
504 Black=0x000000,
505 BlanchedAlmond=0xFFEBCD,
506 Blue=0x0000FF,
507 BlueViolet=0x8A2BE2,
508 Brown=0xA52A2A,
509 BurlyWood=0xDEB887,
510 CadetBlue=0x5F9EA0,
511 Chartreuse=0x7FFF00,
512 Chocolate=0xD2691E,
513 Coral=0xFF7F50,
514 CornflowerBlue=0x6495ED,
515 Cornsilk=0xFFF8DC,
516 Crimson=0xDC143C,
517 Cyan=0x00FFFF,
518 DarkBlue=0x00008B,
519 DarkCyan=0x008B8B,
520 DarkGoldenrod=0xB8860B,
521 DarkGray=0xA9A9A9,
522 DarkGrey=0xA9A9A9,
523 DarkGreen=0x006400,
524 DarkKhaki=0xBDB76B,
525 DarkMagenta=0x8B008B,
526 DarkOliveGreen=0x556B2F,
527 DarkOrange=0xFF8C00,
528 DarkOrchid=0x9932CC,
529 DarkRed=0x8B0000,
530 DarkSalmon=0xE9967A,
531 DarkSeaGreen=0x8FBC8F,
532 DarkSlateBlue=0x483D8B,
533 DarkSlateGray=0x2F4F4F,
534 DarkSlateGrey=0x2F4F4F,
535 DarkTurquoise=0x00CED1,
536 DarkViolet=0x9400D3,
537 DeepPink=0xFF1493,
538 DeepSkyBlue=0x00BFFF,
539 DimGray=0x696969,
540 DimGrey=0x696969,
541 DodgerBlue=0x1E90FF,
542 FireBrick=0xB22222,
543 FloralWhite=0xFFFAF0,
544 ForestGreen=0x228B22,
545 Fuchsia=0xFF00FF,
546 Gainsboro=0xDCDCDC,
547 GhostWhite=0xF8F8FF,
548 Gold=0xFFD700,
549 Goldenrod=0xDAA520,
550 Gray=0x808080,
551 Grey=0x808080,
552 Green=0x008000,
553 GreenYellow=0xADFF2F,
554 Honeydew=0xF0FFF0,
555 HotPink=0xFF69B4,
556 IndianRed=0xCD5C5C,
557 Indigo=0x4B0082,
558 Ivory=0xFFFFF0,
559 Khaki=0xF0E68C,
560 Lavender=0xE6E6FA,
561 LavenderBlush=0xFFF0F5,
562 LawnGreen=0x7CFC00,
563 LemonChiffon=0xFFFACD,
564 LightBlue=0xADD8E6,
565 LightCoral=0xF08080,
566 LightCyan=0xE0FFFF,
568 LightGreen=0x90EE90,
569 LightGrey=0xD3D3D3,
570 LightPink=0xFFB6C1,
571 LightSalmon=0xFFA07A,
572 LightSeaGreen=0x20B2AA,
573 LightSkyBlue=0x87CEFA,
574 LightSlateGray=0x778899,
575 LightSlateGrey=0x778899,
576 LightSteelBlue=0xB0C4DE,
577 LightYellow=0xFFFFE0,
578 Lime=0x00FF00,
579 LimeGreen=0x32CD32,
580 Linen=0xFAF0E6,
581 Magenta=0xFF00FF,
582 Maroon=0x800000,
584 MediumBlue=0x0000CD,
585 MediumOrchid=0xBA55D3,
586 MediumPurple=0x9370DB,
587 MediumSeaGreen=0x3CB371,
592 MidnightBlue=0x191970,
593 MintCream=0xF5FFFA,
594 MistyRose=0xFFE4E1,
595 Moccasin=0xFFE4B5,
596 NavajoWhite=0xFFDEAD,
597 Navy=0x000080,
598 OldLace=0xFDF5E6,
599 Olive=0x808000,
600 OliveDrab=0x6B8E23,
601 Orange=0xFFA500,
602 OrangeRed=0xFF4500,
603 Orchid=0xDA70D6,
604 PaleGoldenrod=0xEEE8AA,
605 PaleGreen=0x98FB98,
606 PaleTurquoise=0xAFEEEE,
607 PaleVioletRed=0xDB7093,
608 PapayaWhip=0xFFEFD5,
609 PeachPuff=0xFFDAB9,
610 Peru=0xCD853F,
611 Pink=0xFFC0CB,
612 Plaid=0xCC5533,
613 Plum=0xDDA0DD,
614 PowderBlue=0xB0E0E6,
615 Purple=0x800080,
616 Red=0xFF0000,
617 RosyBrown=0xBC8F8F,
618 RoyalBlue=0x4169E1,
619 SaddleBrown=0x8B4513,
620 Salmon=0xFA8072,
621 SandyBrown=0xF4A460,
622 SeaGreen=0x2E8B57,
623 Seashell=0xFFF5EE,
624 Sienna=0xA0522D,
625 Silver=0xC0C0C0,
626 SkyBlue=0x87CEEB,
627 SlateBlue=0x6A5ACD,
628 SlateGray=0x708090,
629 SlateGrey=0x708090,
630 Snow=0xFFFAFA,
631 SpringGreen=0x00FF7F,
632 SteelBlue=0x4682B4,
633 Tan=0xD2B48C,
634 Teal=0x008080,
635 Thistle=0xD8BFD8,
636 Tomato=0xFF6347,
637 Turquoise=0x40E0D0,
638 Violet=0xEE82EE,
639 Wheat=0xF5DEB3,
640 White=0xFFFFFF,
641 WhiteSmoke=0xF5F5F5,
642 Yellow=0xFFFF00,
643 YellowGreen=0x9ACD32,
644
645 // LED RGB color that roughly approximates
646 // the color of incandescent fairy lights,
647 // assuming that you're using FastLED
648 // color correction on your LEDs (recommended).
649 FairyLight=0xFFE42D,
650
651 // If you are using no color correction, use this
653
655};
656
657
659FASTLED_FORCE_INLINE bool operator== (const CRGB& lhs, const CRGB& rhs)
660{
661 return (lhs.r == rhs.r) && (lhs.g == rhs.g) && (lhs.b == rhs.b);
662}
663
665FASTLED_FORCE_INLINE bool operator!= (const CRGB& lhs, const CRGB& rhs)
666{
667 return !(lhs == rhs);
668}
669
671FASTLED_FORCE_INLINE bool operator== (const CHSV& lhs, const CHSV& rhs)
672{
673 return (lhs.h == rhs.h) && (lhs.s == rhs.s) && (lhs.v == rhs.v);
674}
675
677FASTLED_FORCE_INLINE bool operator!= (const CHSV& lhs, const CHSV& rhs)
678{
679 return !(lhs == rhs);
680}
681
683FASTLED_FORCE_INLINE bool operator< (const CRGB& lhs, const CRGB& rhs)
684{
685 uint16_t sl, sr;
686 sl = lhs.r + lhs.g + lhs.b;
687 sr = rhs.r + rhs.g + rhs.b;
688 return sl < sr;
689}
690
692FASTLED_FORCE_INLINE bool operator> (const CRGB& lhs, const CRGB& rhs)
693{
694 uint16_t sl, sr;
695 sl = lhs.r + lhs.g + lhs.b;
696 sr = rhs.r + rhs.g + rhs.b;
697 return sl > sr;
698}
699
701FASTLED_FORCE_INLINE bool operator>= (const CRGB& lhs, const CRGB& rhs)
702{
703 uint16_t sl, sr;
704 sl = lhs.r + lhs.g + lhs.b;
705 sr = rhs.r + rhs.g + rhs.b;
706 return sl >= sr;
707}
708
710FASTLED_FORCE_INLINE bool operator<= (const CRGB& lhs, const CRGB& rhs)
711{
712 uint16_t sl, sr;
713 sl = lhs.r + lhs.g + lhs.b;
714 sr = rhs.r + rhs.g + rhs.b;
715 return sl <= sr;
716}
717
718
719
722{
723 return CRGB( p1.r/d, p1.g/d, p1.b/d);
724}
725
726
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
737{
738 return CRGB( p1.r > p2.r ? p1.r : p2.r,
739 p1.g > p2.g ? p1.g : p2.g,
740 p1.b > p2.b ? p1.b : p2.b);
741}
742
744FASTLED_FORCE_INLINE CRGB operator+( const CRGB& p1, const CRGB& p2);
745
747FASTLED_FORCE_INLINE CRGB operator-( const CRGB& p1, const CRGB& p2);
748
750FASTLED_FORCE_INLINE CRGB operator*( const CRGB& p1, uint8_t d);
751
753FASTLED_FORCE_INLINE CRGB operator%( const CRGB& p1, uint8_t d);
754
756
757
759
760
int x
Definition Audio.ino:71
UISlider scale("Scale", 1.0f, 0.0f, 1.0f, 0.01f)
Defines the hue, saturation, and value (HSV) pixel struct.
Definition str.h:388
#define FASTLED_FORCE_INLINE
Definition force_inline.h:6
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:665
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:710
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
Definition crgb.h:659
FASTLED_FORCE_INLINE CRGB operator/(const CRGB &p1, uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:721
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
Definition crgb.hpp:201
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:185
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:683
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:736
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:728
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:692
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:701
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:193
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:177
Defines fractional types used for lib8tion functions.
#define FASTLED_NAMESPACE_END
Definition namespace.h:23
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:69
static void downscale(const CRGB *src, const fl::XYMap &srcXY, CRGB *dst, const fl::XYMap &dstXY)
Downscale an CRGB matrix (or strip) to the smaller size.
Definition crgb.cpp:73
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()=default
Default constructor.
uint8_t getLuma() const
Get the "luma" of a CRGB object.
Definition crgb.hpp:138
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:419
FASTLED_FORCE_INLINE CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
Definition crgb.h:245
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:81
constexpr CRGB(ColorTemperature colorcode) noexcept
Allow construction from a ColorTemperature enum.
Definition crgb.h:138
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:39
constexpr uint32_t as_uint32_t() const noexcept
Definition crgb.h:122
constexpr CRGB(uint32_t colorcode) noexcept
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
Definition crgb.h:117
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:164
CRGB & operator+=(const CRGB &rhs)
Add one CRGB to another, saturating at 0xFF for each channel.
Definition crgb.cpp:94
FASTLED_FORCE_INLINE CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
Definition crgb.hpp:30
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:88
FASTLED_FORCE_INLINE CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
Definition crgb.h:169
FASTLED_FORCE_INLINE CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
Definition crgb.h:205
static CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Definition crgb.cpp:54
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:447
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:29
FASTLED_FORCE_INLINE CRGB(const CHSV &rhs)
Allow construction from a CHSV color.
Definition crgb.h:147
FASTLED_FORCE_INLINE CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
Definition crgb.h:181
FASTLED_FORCE_INLINE CRGB & operator--()
Subtract a constant of '1' from each channel, saturating at 0x00.
Definition crgb.hpp:88
CRGB lerp8(const CRGB &other, fract8 amountOf2) const
Return a new CRGB object after performing a linear interpolation between this object and the passed i...
Definition crgb.cpp:101
FASTLED_FORCE_INLINE CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
Definition crgb.h:254
constexpr CRGB operator-() const
Invert each channel.
Definition crgb.h:359
FASTLED_FORCE_INLINE uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
Definition crgb.h:89
FASTLED_FORCE_INLINE CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
Definition crgb.h:326
FASTLED_FORCE_INLINE uint8_t getAverageLight() const
Get the average of the R, G, and B values.
Definition crgb.hpp:149
FASTLED_FORCE_INLINE CRGB & subtractFromRGB(uint8_t d)
Subtract a constant from each channel, saturating at 0x00.
Definition crgb.hpp:53
constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
Allow construction from red, green, and blue.
Definition crgb.h:110
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:121
static void upscale(const CRGB *src, const fl::XYMap &srcXY, CRGB *dst, const fl::XYMap &dstXY)
Definition crgb.cpp:78
fl::Str toString() const
Definition crgb.cpp:17
FASTLED_FORCE_INLINE CRGB & operator*=(uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
Definition crgb.hpp:61
static CRGB blendAlphaMaxChannel(const CRGB &upper, const CRGB &lower)
Definition crgb.cpp:59
FASTLED_FORCE_INLINE CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
Definition crgb.h:190
FASTLED_FORCE_INLINE CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
Definition crgb.hpp:75
FASTLED_FORCE_INLINE void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
Definition crgb.h:392
constexpr CRGB(LEDColorCorrection colorcode) noexcept
Allow construction from a LEDColorCorrection enum.
Definition crgb.h:131
HTMLColorCode
Predefined RGB colors.
Definition crgb.h:495
@ DarkGray
<div style='background:#A9A9A9;width:4em;height:4em;'></div>
Definition crgb.h:521
@ Sienna
<div style='background:#A0522D;width:4em;height:4em;'></div>
Definition crgb.h:624
@ Plum
<div style='background:#DDA0DD;width:4em;height:4em;'></div>
Definition crgb.h:613
@ GhostWhite
<div style='background:#F8F8FF;width:4em;height:4em;'></div>
Definition crgb.h:547
@ Tan
<div style='background:#D2B48C;width:4em;height:4em;'></div>
Definition crgb.h:633
@ Gold
<div style='background:#FFD700;width:4em;height:4em;'></div>
Definition crgb.h:548
@ DarkRed
<div style='background:#8B0000;width:4em;height:4em;'></div>
Definition crgb.h:529
@ DarkSlateGray
<div style='background:#2F4F4F;width:4em;height:4em;'></div>
Definition crgb.h:533
@ OldLace
<div style='background:#FDF5E6;width:4em;height:4em;'></div>
Definition crgb.h:598
@ Aquamarine
<div style='background:#7FFFD4;width:4em;height:4em;'></div>
Definition crgb.h:500
@ Violet
<div style='background:#EE82EE;width:4em;height:4em;'></div>
Definition crgb.h:638
@ Salmon
<div style='background:#FA8072;width:4em;height:4em;'></div>
Definition crgb.h:620
@ Thistle
<div style='background:#D8BFD8;width:4em;height:4em;'></div>
Definition crgb.h:635
@ Cornsilk
<div style='background:#FFF8DC;width:4em;height:4em;'></div>
Definition crgb.h:515
@ MediumVioletRed
<div style='background:#C71585;width:4em;height:4em;'></div>
Definition crgb.h:591
@ Coral
<div style='background:#FF7F50;width:4em;height:4em;'></div>
Definition crgb.h:513
@ LightPink
<div style='background:#FFB6C1;width:4em;height:4em;'></div>
Definition crgb.h:570
@ DarkGrey
<div style='background:#A9A9A9;width:4em;height:4em;'></div>
Definition crgb.h:522
@ SlateGrey
<div style='background:#708090;width:4em;height:4em;'></div>
Definition crgb.h:629
@ NavajoWhite
<div style='background:#FFDEAD;width:4em;height:4em;'></div>
Definition crgb.h:596
@ PaleVioletRed
<div style='background:#DB7093;width:4em;height:4em;'></div>
Definition crgb.h:607
@ HotPink
<div style='background:#FF69B4;width:4em;height:4em;'></div>
Definition crgb.h:555
@ BlanchedAlmond
<div style='background:#FFEBCD;width:4em;height:4em;'></div>
Definition crgb.h:505
@ RosyBrown
<div style='background:#BC8F8F;width:4em;height:4em;'></div>
Definition crgb.h:617
@ White
<div style='background:#FFFFFF;width:4em;height:4em;'></div>
Definition crgb.h:640
@ Moccasin
<div style='background:#FFE4B5;width:4em;height:4em;'></div>
Definition crgb.h:595
@ LightYellow
<div style='background:#FFFFE0;width:4em;height:4em;'></div>
Definition crgb.h:577
@ Bisque
<div style='background:#FFE4C4;width:4em;height:4em;'></div>
Definition crgb.h:503
@ DeepPink
<div style='background:#FF1493;width:4em;height:4em;'></div>
Definition crgb.h:537
@ Wheat
<div style='background:#F5DEB3;width:4em;height:4em;'></div>
Definition crgb.h:639
@ MediumOrchid
<div style='background:#BA55D3;width:4em;height:4em;'></div>
Definition crgb.h:585
@ Goldenrod
<div style='background:#DAA520;width:4em;height:4em;'></div>
Definition crgb.h:549
@ Orange
<div style='background:#FFA500;width:4em;height:4em;'></div>
Definition crgb.h:601
@ MediumSpringGreen
<div style='background:#00FA9A;width:4em;height:4em;'></div>
Definition crgb.h:589
@ Seashell
<div style='background:#FFF5EE;width:4em;height:4em;'></div>
Definition crgb.h:623
@ DarkViolet
<div style='background:#9400D3;width:4em;height:4em;'></div>
Definition crgb.h:536
@ Ivory
<div style='background:#FFFFF0;width:4em;height:4em;'></div>
Definition crgb.h:558
@ Teal
<div style='background:#008080;width:4em;height:4em;'></div>
Definition crgb.h:634
@ Gray
<div style='background:#808080;width:4em;height:4em;'></div>
Definition crgb.h:550
@ MistyRose
<div style='background:#FFE4E1;width:4em;height:4em;'></div>
Definition crgb.h:594
@ SlateBlue
<div style='background:#6A5ACD;width:4em;height:4em;'></div>
Definition crgb.h:627
@ Silver
<div style='background:#C0C0C0;width:4em;height:4em;'></div>
Definition crgb.h:625
@ Purple
<div style='background:#800080;width:4em;height:4em;'></div>
Definition crgb.h:615
@ DarkKhaki
<div style='background:#BDB76B;width:4em;height:4em;'></div>
Definition crgb.h:524
@ SaddleBrown
<div style='background:#8B4513;width:4em;height:4em;'></div>
Definition crgb.h:619
@ LemonChiffon
<div style='background:#FFFACD;width:4em;height:4em;'></div>
Definition crgb.h:563
@ Magenta
<div style='background:#FF00FF;width:4em;height:4em;'></div>
Definition crgb.h:581
@ Beige
<div style='background:#F5F5DC;width:4em;height:4em;'></div>
Definition crgb.h:502
@ Crimson
<div style='background:#DC143C;width:4em;height:4em;'></div>
Definition crgb.h:516
@ MediumAquamarine
<div style='background:#66CDAA;width:4em;height:4em;'></div>
Definition crgb.h:583
@ LawnGreen
<div style='background:#7CFC00;width:4em;height:4em;'></div>
Definition crgb.h:562
@ DodgerBlue
<div style='background:#1E90FF;width:4em;height:4em;'></div>
Definition crgb.h:541
@ Tomato
<div style='background:#FF6347;width:4em;height:4em;'></div>
Definition crgb.h:636
@ Fuchsia
<div style='background:#FF00FF;width:4em;height:4em;'></div>
Definition crgb.h:545
@ Aqua
<div style='background:#00FFFF;width:4em;height:4em;'></div>
Definition crgb.h:499
@ Brown
<div style='background:#A52A2A;width:4em;height:4em;'></div>
Definition crgb.h:508
@ Pink
<div style='background:#FFC0CB;width:4em;height:4em;'></div>
Definition crgb.h:611
@ Lavender
<div style='background:#E6E6FA;width:4em;height:4em;'></div>
Definition crgb.h:560
@ YellowGreen
<div style='background:#9ACD32;width:4em;height:4em;'></div>
Definition crgb.h:643
@ DeepSkyBlue
<div style='background:#00BFFF;width:4em;height:4em;'></div>
Definition crgb.h:538
@ Turquoise
<div style='background:#40E0D0;width:4em;height:4em;'></div>
Definition crgb.h:637
@ SandyBrown
<div style='background:#F4A460;width:4em;height:4em;'></div>
Definition crgb.h:621
@ MediumSlateBlue
<div style='background:#7B68EE;width:4em;height:4em;'></div>
Definition crgb.h:588
@ PeachPuff
<div style='background:#FFDAB9;width:4em;height:4em;'></div>
Definition crgb.h:609
@ Orchid
<div style='background:#DA70D6;width:4em;height:4em;'></div>
Definition crgb.h:603
@ Green
<div style='background:#008000;width:4em;height:4em;'></div>
Definition crgb.h:552
@ SteelBlue
<div style='background:#4682B4;width:4em;height:4em;'></div>
Definition crgb.h:632
@ CornflowerBlue
<div style='background:#6495ED;width:4em;height:4em;'></div>
Definition crgb.h:514
@ DarkSalmon
<div style='background:#E9967A;width:4em;height:4em;'></div>
Definition crgb.h:530
@ SkyBlue
<div style='background:#87CEEB;width:4em;height:4em;'></div>
Definition crgb.h:626
@ LightSalmon
<div style='background:#FFA07A;width:4em;height:4em;'></div>
Definition crgb.h:571
@ RoyalBlue
<div style='background:#4169E1;width:4em;height:4em;'></div>
Definition crgb.h:618
@ DarkSlateGrey
<div style='background:#2F4F4F;width:4em;height:4em;'></div>
Definition crgb.h:534
@ Navy
<div style='background:#000080;width:4em;height:4em;'></div>
Definition crgb.h:597
@ Lime
<div style='background:#00FF00;width:4em;height:4em;'></div>
Definition crgb.h:578
@ LightCoral
<div style='background:#F08080;width:4em;height:4em;'></div>
Definition crgb.h:565
@ PaleTurquoise
<div style='background:#AFEEEE;width:4em;height:4em;'></div>
Definition crgb.h:606
@ BurlyWood
<div style='background:#DEB887;width:4em;height:4em;'></div>
Definition crgb.h:509
@ DarkTurquoise
<div style='background:#00CED1;width:4em;height:4em;'></div>
Definition crgb.h:535
@ DarkMagenta
<div style='background:#8B008B;width:4em;height:4em;'></div>
Definition crgb.h:525
@ LightSeaGreen
<div style='background:#20B2AA;width:4em;height:4em;'></div>
Definition crgb.h:572
@ MidnightBlue
<div style='background:#191970;width:4em;height:4em;'></div>
Definition crgb.h:592
@ LightSlateGray
<div style='background:#778899;width:4em;height:4em;'></div>
Definition crgb.h:574
@ Chocolate
<div style='background:#D2691E;width:4em;height:4em;'></div>
Definition crgb.h:512
@ Linen
<div style='background:#FAF0E6;width:4em;height:4em;'></div>
Definition crgb.h:580
@ SeaGreen
<div style='background:#2E8B57;width:4em;height:4em;'></div>
Definition crgb.h:622
@ Cyan
<div style='background:#00FFFF;width:4em;height:4em;'></div>
Definition crgb.h:517
@ AntiqueWhite
<div style='background:#FAEBD7;width:4em;height:4em;'></div>
Definition crgb.h:498
@ LimeGreen
<div style='background:#32CD32;width:4em;height:4em;'></div>
Definition crgb.h:579
@ MediumTurquoise
<div style='background:#48D1CC;width:4em;height:4em;'></div>
Definition crgb.h:590
@ LightGreen
<div style='background:#90EE90;width:4em;height:4em;'></div>
Definition crgb.h:568
@ MediumSeaGreen
<div style='background:#3CB371;width:4em;height:4em;'></div>
Definition crgb.h:587
@ PaleGreen
<div style='background:#98FB98;width:4em;height:4em;'></div>
Definition crgb.h:605
@ FireBrick
<div style='background:#B22222;width:4em;height:4em;'></div>
Definition crgb.h:542
@ Amethyst
<div style='background:#9966CC;width:4em;height:4em;'></div>
Definition crgb.h:497
@ LightSteelBlue
<div style='background:#B0C4DE;width:4em;height:4em;'></div>
Definition crgb.h:576
@ LightGrey
<div style='background:#D3D3D3;width:4em;height:4em;'></div>
Definition crgb.h:569
@ BlueViolet
<div style='background:#8A2BE2;width:4em;height:4em;'></div>
Definition crgb.h:507
@ Indigo
<div style='background:#4B0082;width:4em;height:4em;'></div>
Definition crgb.h:557
@ LightCyan
<div style='background:#E0FFFF;width:4em;height:4em;'></div>
Definition crgb.h:566
@ Olive
<div style='background:#808000;width:4em;height:4em;'></div>
Definition crgb.h:599
@ PapayaWhip
<div style='background:#FFEFD5;width:4em;height:4em;'></div>
Definition crgb.h:608
@ Azure
<div style='background:#F0FFFF;width:4em;height:4em;'></div>
Definition crgb.h:501
@ Blue
<div style='background:#0000FF;width:4em;height:4em;'></div>
Definition crgb.h:506
@ DarkOrchid
<div style='background:#9932CC;width:4em;height:4em;'></div>
Definition crgb.h:528
@ Red
<div style='background:#FF0000;width:4em;height:4em;'></div>
Definition crgb.h:616
@ PowderBlue
<div style='background:#B0E0E6;width:4em;height:4em;'></div>
Definition crgb.h:614
@ IndianRed
<div style='background:#CD5C5C;width:4em;height:4em;'></div>
Definition crgb.h:556
@ FairyLight
<div style='background:#FFE42D;width:4em;height:4em;'></div>
Definition crgb.h:649
@ DarkGoldenrod
<div style='background:#B8860B;width:4em;height:4em;'></div>
Definition crgb.h:520
@ LightSkyBlue
<div style='background:#87CEFA;width:4em;height:4em;'></div>
Definition crgb.h:573
@ DarkSlateBlue
<div style='background:#483D8B;width:4em;height:4em;'></div>
Definition crgb.h:532
@ MediumBlue
<div style='background:#0000CD;width:4em;height:4em;'></div>
Definition crgb.h:584
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Definition crgb.h:504
@ LavenderBlush
<div style='background:#FFF0F5;width:4em;height:4em;'></div>
Definition crgb.h:561
@ DarkOrange
<div style='background:#FF8C00;width:4em;height:4em;'></div>
Definition crgb.h:527
@ CadetBlue
<div style='background:#5F9EA0;width:4em;height:4em;'></div>
Definition crgb.h:510
@ SlateGray
<div style='background:#708090;width:4em;height:4em;'></div>
Definition crgb.h:628
@ OliveDrab
<div style='background:#6B8E23;width:4em;height:4em;'></div>
Definition crgb.h:600
@ Plaid
<div style='background:#CC5533;width:4em;height:4em;'></div>
Definition crgb.h:612
@ SpringGreen
<div style='background:#00FF7F;width:4em;height:4em;'></div>
Definition crgb.h:631
@ Honeydew
<div style='background:#F0FFF0;width:4em;height:4em;'></div>
Definition crgb.h:554
@ Gainsboro
<div style='background:#DCDCDC;width:4em;height:4em;'></div>
Definition crgb.h:546
@ MediumPurple
<div style='background:#9370DB;width:4em;height:4em;'></div>
Definition crgb.h:586
@ Yellow
<div style='background:#FFFF00;width:4em;height:4em;'></div>
Definition crgb.h:642
@ DimGrey
<div style='background:#696969;width:4em;height:4em;'></div>
Definition crgb.h:540
@ FairyLightNCC
<div style='background:#FFE42D;width:4em;height:4em;'></div>
Definition crgb.h:652
@ DarkOliveGreen
<div style='background:#556B2F;width:4em;height:4em;'></div>
Definition crgb.h:526
@ LightGoldenrodYellow
<div style='background:#FAFAD2;width:4em;height:4em;'></div>
Definition crgb.h:567
@ LightSlateGrey
<div style='background:#778899;width:4em;height:4em;'></div>
Definition crgb.h:575
@ Peru
<div style='background:#CD853F;width:4em;height:4em;'></div>
Definition crgb.h:610
@ AliceBlue
<div style='background:#F0F8FF;width:4em;height:4em;'></div>
Definition crgb.h:496
@ PaleGoldenrod
<div style='background:#EEE8AA;width:4em;height:4em;'></div>
Definition crgb.h:604
@ DarkSeaGreen
<div style='background:#8FBC8F;width:4em;height:4em;'></div>
Definition crgb.h:531
@ LightBlue
<div style='background:#ADD8E6;width:4em;height:4em;'></div>
Definition crgb.h:564
@ FloralWhite
<div style='background:#FFFAF0;width:4em;height:4em;'></div>
Definition crgb.h:543
@ Chartreuse
<div style='background:#7FFF00;width:4em;height:4em;'></div>
Definition crgb.h:511
@ DimGray
<div style='background:#696969;width:4em;height:4em;'></div>
Definition crgb.h:539
@ OrangeRed
<div style='background:#FF4500;width:4em;height:4em;'></div>
Definition crgb.h:602
@ ForestGreen
<div style='background:#228B22;width:4em;height:4em;'></div>
Definition crgb.h:544
@ Khaki
<div style='background:#F0E68C;width:4em;height:4em;'></div>
Definition crgb.h:559
@ MintCream
<div style='background:#F5FFFA;width:4em;height:4em;'></div>
Definition crgb.h:593
@ DarkCyan
<div style='background:#008B8B;width:4em;height:4em;'></div>
Definition crgb.h:519
@ Snow
<div style='background:#FFFAFA;width:4em;height:4em;'></div>
Definition crgb.h:630
@ DarkGreen
<div style='background:#006400;width:4em;height:4em;'></div>
Definition crgb.h:523
@ GreenYellow
<div style='background:#ADFF2F;width:4em;height:4em;'></div>
Definition crgb.h:553
@ WhiteSmoke
<div style='background:#F5F5F5;width:4em;height:4em;'></div>
Definition crgb.h:641
@ DarkBlue
<div style='background:#00008B;width:4em;height:4em;'></div>
Definition crgb.h:518
@ Maroon
<div style='background:#800000;width:4em;height:4em;'></div>
Definition crgb.h:582
@ Grey
<div style='background:#808080;width:4em;height:4em;'></div>
Definition crgb.h:551
CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
Definition crgb.cpp:111
constexpr CRGB nscale8_constexpr(const CRGB scaledown) const
Definition crgb.hpp:103
FASTLED_FORCE_INLINE CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Definition crgb.h:308
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55