12#include "fl/force_inline.h"
13#include "fl/template_magic.h"
23#ifndef FASTLED_HD_COLOR_MIXING
26#define FASTLED_HD_COLOR_MIXING 0
28#define FASTLED_HD_COLOR_MIXING 1
91 FASTLED_FORCE_INLINE
const uint8_t&
operator[] (uint8_t x)
const
98 FASTLED_FORCE_INLINE
CRGB() =
default;
104 constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
105 :
r(ir),
g(ig),
b(ib)
111 constexpr CRGB(uint32_t colorcode) noexcept
112 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
116 constexpr uint32_t as_uint32_t() const noexcept {
117 return uint32_t(0xff000000) |
118 (uint32_t{
r} << 16) |
126 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
133 :
r((colorcode >> 16) & 0xFF),
g((colorcode >> 8) & 0xFF),
b((colorcode >> 0) & 0xFF)
138 FASTLED_FORCE_INLINE
CRGB(
const CRGB& rhs) =
default;
153 r = (colorcode >> 16) & 0xFF;
154 g = (colorcode >> 8) & 0xFF;
155 b = (colorcode >> 0) & 0xFF;
163 FASTLED_FORCE_INLINE
CRGB&
setRGB (uint8_t nr, uint8_t ng, uint8_t nb)
175 FASTLED_FORCE_INLINE
CRGB&
setHSV (uint8_t hue, uint8_t sat, uint8_t val)
201 r = (colorcode >> 16) & 0xFF;
202 g = (colorcode >> 8) & 0xFF;
203 b = (colorcode >> 0) & 0xFF;
280 FASTLED_FORCE_INLINE
CRGB&
nscale8 (uint8_t scaledown );
288 constexpr CRGB nscale8_constexpr (
const CRGB scaledown )
const;
292 FASTLED_FORCE_INLINE
CRGB scale8 (uint8_t scaledown )
const;
304 if( rhs.
r >
r)
r = rhs.
r;
305 if( rhs.
g >
g)
g = rhs.
g;
306 if( rhs.
b >
b)
b = rhs.
b;
322 if( rhs.
r <
r)
r = rhs.
r;
323 if( rhs.
g <
g)
g = rhs.
g;
324 if( rhs.
b <
b)
b = rhs.
b;
338 constexpr explicit operator bool()
const
344 constexpr explicit operator uint32_t()
const
346 return uint32_t(0xff000000) |
347 (uint32_t{
r} << 16) |
355 return CRGB(255 -
r, 255 -
g, 255 -
b);
358#if (defined SmartMatrix_h || defined SmartMatrix3_h)
361 operator rgb24()
const {
374 FASTLED_FORCE_INLINE uint8_t
getLuma()
const;
391 uint16_t factor = ((uint16_t)(limit) * 256) / max;
392 red = (
red * factor) / 256;
413 uint8_t sum =
r +
g +
b;
443 if( parity == curparity)
return;
447 if( (
b > 0) && (
b < 255)) {
448 if(
r ==
g &&
g ==
b) {
453 }
else if( (
r > 0) && (
r < 255)) {
455 }
else if( (
g > 0) && (
g < 255)) {
458 if(
r ==
g &&
g ==
b) {
467 if(
r ==
g &&
g ==
b) {
477 if(
r ==
g &&
g ==
b) {
653 return (lhs.
r == rhs.
r) && (lhs.
g == rhs.
g) && (lhs.
b == rhs.
b);
659 return !(lhs == rhs);
665 return (lhs.
h == rhs.
h) && (lhs.
s == rhs.
s) && (lhs.
v == rhs.
v);
671 return !(lhs == rhs);
678 sl = lhs.
r + lhs.
g + lhs.
b;
679 sr = rhs.
r + rhs.
g + rhs.
b;
687 sl = lhs.
r + lhs.
g + lhs.
b;
688 sr = rhs.
r + rhs.
g + rhs.
b;
696 sl = lhs.
r + lhs.
g + lhs.
b;
697 sr = rhs.
r + rhs.
g + rhs.
b;
705 sl = lhs.
r + lhs.
g + lhs.
b;
706 sr = rhs.
r + rhs.
g + rhs.
b;
715 return CRGB( p1.
r/d, p1.
g/d, p1.
b/d);
722 return CRGB( p1.
r < p2.
r ? p1.
r : p2.
r,
723 p1.
g < p2.
g ? p1.
g : p2.
g,
724 p1.
b < p2.
b ? p1.
b : p2.
b);
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);
Defines the hue, saturation, and value (HSV) pixel struct.
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 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.
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.
FASTLED_FORCE_INLINE CRGB operator%(const CRGB &p1, uint8_t d)
Scale using CRGB::nscale8_video()
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 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 bool operator>(const CRGB &lhs, const CRGB &rhs)
Check if the sum of the color channels in one CRGB object is greater than another.
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.
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.
Defines fractional types used for lib8tion functions.
Implements the FastLED namespace macros.
#define FASTLED_NAMESPACE_END
End of the FastLED namespace.
#define FASTLED_NAMESPACE_BEGIN
Start of the FastLED namespace.
Implements a simple red square effect for 2D LED grids.
Contains definitions for color correction and temperature.
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)
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.
FASTLED_FORCE_INLINE CRGB()=default
Default constructor.
FASTLED_FORCE_INLINE uint8_t getLuma() const
Get the "luma" of a CRGB object.
uint8_t raw[3]
Access the red, green, and blue data as an array.
uint8_t r
Red channel value.
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
constexpr CRGB(ColorTemperature colorcode) noexcept
Allow construction from a ColorTemperature enum.
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.
constexpr CRGB(uint32_t colorcode) noexcept
Allow construction from 32-bit (really 24-bit) bit 0xRRGGBB color code.
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 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...
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,...
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 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>>=(uint8_t d)
Right shift each of the channels by a constant.
constexpr CRGB operator-() const
Invert each channel.
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.
constexpr CRGB(uint8_t ir, uint8_t ig, uint8_t ib) noexcept
Allow construction from red, green, and blue.
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.
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 void maximizeBrightness(uint8_t limit=255)
Maximize the brightness of this CRGB object.
constexpr CRGB(LEDColorCorrection colorcode) noexcept
Allow construction from a LEDColorCorrection enum.
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 &rhs)
"or" operator brings each channel up to the higher of the two values