8#include "lib8tion/types.h"
9#include "force_inline.h"
11FASTLED_NAMESPACE_BEGIN
60 FASTLED_FORCE_INLINE
const uint8_t&
operator[] (uint8_t x)
const
67 FASTLED_FORCE_INLINE
CRGB() =
default;
73 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) __attribute__((always_inline))
80 constexpr CRGB(uint32_t colorcode) __attribute__((always_inline))
81 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
88 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
95 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
100 FASTLED_FORCE_INLINE
CRGB(
const CRGB& rhs) =
default;
115 r = (colorcode >> 16) & 0xFF;
116 g = (colorcode >> 8) & 0xFF;
117 b = (colorcode >> 0) & 0xFF;
125 FASTLED_FORCE_INLINE
CRGB&
setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
137 FASTLED_FORCE_INLINE
CRGB&
setHSV (uint8_t hue, uint8_t sat, uint8_t val)
163 r = (colorcode >> 16) & 0xFF;
164 g = (colorcode >> 8) & 0xFF;
165 b = (colorcode >> 0) & 0xFF;
260 FASTLED_FORCE_INLINE
CRGB&
nscale8 (uint8_t scaledown );
269 FASTLED_FORCE_INLINE
CRGB scale8 (uint8_t scaledown )
const;
281 if( rhs.
r >
r)
r = rhs.
r;
282 if( rhs.
g >
g)
g = rhs.
g;
283 if( rhs.
b >
b)
b = rhs.
b;
299 if( rhs.
r <
r)
r = rhs.
r;
300 if( rhs.
g <
g)
g = rhs.
g;
301 if( rhs.
b <
b)
b = rhs.
b;
315 FASTLED_FORCE_INLINE
explicit operator bool()
const
321 FASTLED_FORCE_INLINE
explicit operator uint32_t()
const
323 return uint32_t(0xff000000) |
324 (uint32_t{
r} << 16) |
339#if (defined SmartMatrix_h || defined SmartMatrix3_h)
342 operator rgb24()
const {
353 FASTLED_FORCE_INLINE uint8_t
getLuma()
const;
370 uint16_t factor = ((uint16_t)(limit) * 256) / max;
371 red = (
red * factor) / 256;
385 uint8_t sum =
r +
g +
b;
415 if( parity == curparity)
return;
419 if( (
b > 0) && (
b < 255)) {
420 if(
r ==
g &&
g ==
b) {
425 }
else if( (
r > 0) && (
r < 255)) {
427 }
else if( (
g > 0) && (
g < 255)) {
430 if(
r ==
g &&
g ==
b) {
439 if(
r ==
g &&
g ==
b) {
449 if(
r ==
g &&
g ==
b) {
625 return (lhs.
r == rhs.
r) && (lhs.
g == rhs.
g) && (lhs.
b == rhs.
b);
631 return !(lhs == rhs);
637 return (lhs.
h == rhs.
h) && (lhs.
s == rhs.
s) && (lhs.
v == rhs.
v);
643 return !(lhs == rhs);
650 sl = lhs.
r + lhs.
g + lhs.
b;
651 sr = rhs.
r + rhs.
g + rhs.
b;
659 sl = lhs.
r + lhs.
g + lhs.
b;
660 sr = rhs.
r + rhs.
g + rhs.
b;
668 sl = lhs.
r + lhs.
g + lhs.
b;
669 sr = rhs.
r + rhs.
g + rhs.
b;
677 sl = lhs.
r + lhs.
g + lhs.
b;
678 sr = rhs.
r + rhs.
g + rhs.
b;
687 return CRGB( p1.
r/d, p1.
g/d, p1.
b/d);
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);
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);
Contains definitions for color correction and temperature.
ColorTemperature
Color temperature values.
LEDColorCorrection
Color correction starting points.
uint8_t fract8
ANSI: unsigned short _Fract.
uint16_t fract16
ANSI: unsigned _Fract.
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.
void hsv2rgb_rainbow(const CHSV &hsv, CRGB &rgb)
Forward declaration of hsv2rgb_rainbow here, to avoid circular dependencies.
FASTLED_FORCE_INLINE CRGB()=default
Default constructor.
FASTLED_FORCE_INLINE uint8_t getLuma() const
Get the "luma" of a CRGB object.
FASTLED_FORCE_INLINE bool operator!=(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects do not have the same color data.
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.
constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib)
Allow construction from red, green, and blue.
FASTLED_FORCE_INLINE bool operator==(const CRGB &lhs, const CRGB &rhs)
Check if two CRGB objects have the same color data.
FASTLED_FORCE_INLINE CRGB operator/(const CRGB &p1, uint8_t d)
Divide each of the channels by a constant.
uint8_t raw[3]
Access the red, green, and blue data as an array.
uint8_t r
Red channel value.
constexpr CRGB(uint32_t colorcode)
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
FASTLED_FORCE_INLINE uint8_t getParity()
Returns 0 or 1, depending on the lowest bit of the sum of the color components.
FASTLED_FORCE_INLINE CRGB & operator/=(uint8_t d)
Divide each of the channels by a constant.
FASTLED_FORCE_INLINE CRGB & fadeLightBy(uint8_t fadefactor)
fadeLightBy is a synonym for nscale8_video(), as a fade instead of a scale
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
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.
FASTLED_FORCE_INLINE CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
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...
FASTLED_FORCE_INLINE CRGB operator-() const
Invert each channel.
FASTLED_FORCE_INLINE CRGB & operator-=(const CRGB &rhs)
Subtract one CRGB from another, saturating at 0x00 for each channel.
FASTLED_FORCE_INLINE CRGB & setRGB(uint8_t nr, uint8_t ng, uint8_t nb)
Allow assignment from red, green, and blue.
FASTLED_FORCE_INLINE CRGB & setColorCode(uint32_t colorcode)
Allow assignment from 32-bit (really 24-bit) 0xRRGGBB color code.
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...
FASTLED_FORCE_INLINE CRGB(const CHSV &rhs)
Allow construction from a CHSV color.
FASTLED_FORCE_INLINE CRGB & setHSV(uint8_t hue, uint8_t sat, uint8_t val)
Allow assignment from hue, saturation, and value.
FASTLED_FORCE_INLINE CRGB & operator--()
Subtract a constant of '1' from each channel, saturating at 0x00.
FASTLED_FORCE_INLINE CRGB operator-(const CRGB &p1, const CRGB &p2)
Subtract one CRGB from another, saturating at 0x00 for each channel.
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.
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...
uint8_t g
Green channel value.
uint8_t red
Red channel value.
FASTLED_FORCE_INLINE CRGB operator|(const CRGB &p1, const CRGB &p2)
Combine two CRGB objects, taking the largest value of each channel.
FASTLED_FORCE_INLINE CRGB operator&(const CRGB &p1, const CRGB &p2)
Combine two CRGB objects, taking the smallest value of each channel.
FASTLED_FORCE_INLINE CRGB & operator>>=(uint8_t d)
Right shift each of the channels by a constant.
FASTLED_FORCE_INLINE CRGB & operator+=(const CRGB &rhs)
Add one CRGB to another, saturating at 0xFF for each channel.
FASTLED_FORCE_INLINE uint8_t & operator[](uint8_t x)
Array access operator to index into the CRGB object.
uint8_t blue
Blue channel value.
FASTLED_FORCE_INLINE CRGB & operator&=(const CRGB &rhs)
"and" operator brings each channel down to the lower of the two values
FASTLED_FORCE_INLINE uint8_t getAverageLight() const
Get the average of the R, G, and B values.
FASTLED_FORCE_INLINE CRGB & addToRGB(uint8_t d)
Add a constant to each channel, saturating at 0xFF.
FASTLED_FORCE_INLINE CRGB & subtractFromRGB(uint8_t d)
Subtract a constant from each channel, saturating at 0x00.
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.
uint8_t b
Blue channel value.
FASTLED_FORCE_INLINE CRGB scale8(uint8_t scaledown) const
Return a CRGB object that is a scaled down version of this object.
uint8_t green
Green channel value.
FASTLED_FORCE_INLINE CRGB & operator*=(uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
constexpr CRGB(LEDColorCorrection colorcode)
Allow construction from a LEDColorCorrection enum.
FASTLED_FORCE_INLINE CRGB & setHue(uint8_t hue)
Allow assignment from just a hue.
FASTLED_FORCE_INLINE CRGB & operator%=(uint8_t scaledown)
%= is a synonym for nscale8_video().
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.
constexpr CRGB(ColorTemperature colorcode)
Allow construction from a ColorTemperature enum.
FASTLED_FORCE_INLINE void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
HTMLColorCode
Predefined RGB colors.
FASTLED_FORCE_INLINE CRGB & fadeToBlackBy(uint8_t fadefactor)
fadeToBlackBy is a synonym for nscale8(), as a fade instead of a scale
FASTLED_FORCE_INLINE CRGB operator*(const CRGB &p1, uint8_t d)
Multiply each of the channels by a constant, saturating each channel at 0xFF.
FASTLED_FORCE_INLINE CRGB operator+(const CRGB &p1, const CRGB &p2)
Add one CRGB to another, saturating at 0xFF for each channel.
FASTLED_FORCE_INLINE CRGB & operator|=(const CRGB &rhs)
"or" operator brings each channel up to the higher of the two values
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
uint8_t v
Color value (brightness).
uint8_t s
Color saturation.
Representation of an RGB pixel (Red, Green, Blue)