FastLED 3.9.7
Loading...
Searching...
No Matches
Color Fill Functions

Detailed Description

Functions for filling LED arrays with colors and gradients

Macros

#define saccum87   int16_t
 ANSI: signed short _Accum.
 
#define fill_gradient_HSV   fill_gradient
 Convenience synonym.
 

Enumerations

enum  TGradientDirectionCode { FORWARD_HUES , BACKWARD_HUES , SHORTEST_HUES , LONGEST_HUES }
 Hue direction for calculating fill gradients. More...
 

Functions

void fill_solid (struct CRGB *targetArray, int numToFill, const struct CRGB &color)
 Fill a range of LEDs with a solid color.
 
void fill_solid (struct CHSV *targetArray, int numToFill, const struct CHSV &color)
 Fill a range of LEDs with a solid color.
 
void fill_rainbow (struct CRGB *targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
 Fill a range of LEDs with a rainbow of colors.
 
void fill_rainbow (struct CHSV *targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
 Fill a range of LEDs with a rainbow of colors.
 
void fill_rainbow_circular (struct CRGB *targetArray, int numToFill, uint8_t initialhue, bool reversed=false)
 Fill a range of LEDs with a rainbow of colors, so that the hues are continuous between the end of the strip and the beginning.
 
void fill_rainbow_circular (struct CHSV *targetArray, int numToFill, uint8_t initialhue, bool reversed=false)
 Fill a range of LEDs with a rainbow of colors, so that the hues are continuous between the end of the strip and the beginning.
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t startpos, CHSV startcolor, uint16_t endpos, CHSV endcolor, TGradientDirectionCode directionCode=SHORTEST_HUES)
 Fill a range of LEDs with a smooth HSV gradient between two HSV colors.
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t numLeds, const CHSV &c1, const CHSV &c2, TGradientDirectionCode directionCode=SHORTEST_HUES)
 Fill a range of LEDs with a smooth HSV gradient between two HSV colors.
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t numLeds, const CHSV &c1, const CHSV &c2, const CHSV &c3, TGradientDirectionCode directionCode=SHORTEST_HUES)
 Fill a range of LEDs with a smooth HSV gradient between three HSV colors.
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t numLeds, const CHSV &c1, const CHSV &c2, const CHSV &c3, const CHSV &c4, TGradientDirectionCode directionCode=SHORTEST_HUES)
 Fill a range of LEDs with a smooth HSV gradient between four HSV colors.
 
void fill_gradient_RGB (CRGB *leds, uint16_t startpos, CRGB startcolor, uint16_t endpos, CRGB endcolor)
 Fill a range of LEDs with a smooth RGB gradient between two RGB colors.
 
void fill_gradient_RGB (CRGB *leds, uint16_t numLeds, const CRGB &c1, const CRGB &c2)
 Fill a range of LEDs with a smooth RGB gradient between two RGB colors.
 
void fill_gradient_RGB (CRGB *leds, uint16_t numLeds, const CRGB &c1, const CRGB &c2, const CRGB &c3)
 Fill a range of LEDs with a smooth RGB gradient between three RGB colors.
 
void fill_gradient_RGB (CRGB *leds, uint16_t numLeds, const CRGB &c1, const CRGB &c2, const CRGB &c3, const CRGB &c4)
 Fill a range of LEDs with a smooth RGB gradient between four RGB colors.
 
CRGB HeatColor (uint8_t temperature)
 Approximates a "black body radiation" spectrum for a given "heat" level.
 

Macro Definition Documentation

◆ fill_gradient_HSV

#define fill_gradient_HSV   fill_gradient

Convenience synonym.

Definition at line 350 of file colorutils.h.

◆ saccum87

#define saccum87   int16_t

ANSI: signed short _Accum.

8 bits int, 7 bits fraction

See also
accum88

Definition at line 167 of file colorutils.h.

Enumeration Type Documentation

◆ TGradientDirectionCode

Hue direction for calculating fill gradients.

Since "hue" is a value around a color wheel, there are always two directions to sweep from one hue to another.

Enumerator
FORWARD_HUES 

Hue always goes clockwise around the color wheel.

BACKWARD_HUES 

Hue always goes counter-clockwise around the color wheel.

SHORTEST_HUES 

Hue goes whichever way is shortest.

LONGEST_HUES 

Hue goes whichever way is longest.

Definition at line 157 of file colorutils.h.

Function Documentation

◆ fill_gradient() [1/4]

template<typename T >
void fill_gradient ( T * targetArray,
uint16_t numLeds,
const CHSV & c1,
const CHSV & c2,
const CHSV & c3,
const CHSV & c4,
TGradientDirectionCode directionCode = SHORTEST_HUES )

Fill a range of LEDs with a smooth HSV gradient between four HSV colors.

See also
fill_gradient()
Parameters
targetArraya pointer to the color array to fill
numLedsthe number of LEDs to fill
c1the starting color in the gradient
c2the first middle color for the gradient
c3the second middle color for the gradient
c4the end color for the gradient
directionCodethe direction to travel around the color wheel

Definition at line 337 of file colorutils.h.

◆ fill_gradient() [2/4]

template<typename T >
void fill_gradient ( T * targetArray,
uint16_t numLeds,
const CHSV & c1,
const CHSV & c2,
const CHSV & c3,
TGradientDirectionCode directionCode = SHORTEST_HUES )

Fill a range of LEDs with a smooth HSV gradient between three HSV colors.

See also
fill_gradient()
Parameters
targetArraya pointer to the color array to fill
numLedsthe number of LEDs to fill
c1the starting color in the gradient
c2the middle color for the gradient
c3the end color for the gradient
directionCodethe direction to travel around the color wheel

Definition at line 317 of file colorutils.h.

◆ fill_gradient() [3/4]

template<typename T >
void fill_gradient ( T * targetArray,
uint16_t numLeds,
const CHSV & c1,
const CHSV & c2,
TGradientDirectionCode directionCode = SHORTEST_HUES )

Fill a range of LEDs with a smooth HSV gradient between two HSV colors.

See also
fill_gradient()
Parameters
targetArraya pointer to the color array to fill
numLedsthe number of LEDs to fill
c1the starting color in the gradient
c2the end color for the gradient
directionCodethe direction to travel around the color wheel

Definition at line 301 of file colorutils.h.

◆ fill_gradient() [4/4]

template<typename T >
void fill_gradient ( T * targetArray,
uint16_t startpos,
CHSV startcolor,
uint16_t endpos,
CHSV endcolor,
TGradientDirectionCode directionCode = SHORTEST_HUES )

Fill a range of LEDs with a smooth HSV gradient between two HSV colors.

This function can write the gradient colors either:

  1. Into an array of CRGBs (e.g., an leds[] array, or a CRGB palette)
  2. Into an array of CHSVs (e.g. a CHSV palette).

In the case of writing into a CRGB array, the gradient is computed in HSV space, and then HSV values are converted to RGB as they're written into the CRGB array.

Parameters
targetArraya pointer to the color array to fill
startposthe starting position in the array
startcolorthe starting color for the gradient
endposthe ending position in the array
endcolorthe end color for the gradient
directionCodethe direction to travel around the color wheel

Definition at line 186 of file colorutils.h.

◆ fill_gradient_RGB() [1/4]

void fill_gradient_RGB ( CRGB * leds,
uint16_t numLeds,
const CRGB & c1,
const CRGB & c2 )

Fill a range of LEDs with a smooth RGB gradient between two RGB colors.

See also
fill_gradient_RGB()
Parameters
ledsa pointer to the LED array to fill
numLedsthe number of LEDs to fill
c1the starting color in the gradient
c2the end color for the gradient

Definition at line 192 of file colorutils.cpp.

◆ fill_gradient_RGB() [2/4]

void fill_gradient_RGB ( CRGB * leds,
uint16_t numLeds,
const CRGB & c1,
const CRGB & c2,
const CRGB & c3 )

Fill a range of LEDs with a smooth RGB gradient between three RGB colors.

See also
fill_gradient_RGB()
Parameters
ledsa pointer to the LED array to fill
numLedsthe number of LEDs to fill
c1the starting color in the gradient
c2the middle color for the gradient
c3the end color for the gradient

Definition at line 199 of file colorutils.cpp.

◆ fill_gradient_RGB() [3/4]

void fill_gradient_RGB ( CRGB * leds,
uint16_t numLeds,
const CRGB & c1,
const CRGB & c2,
const CRGB & c3,
const CRGB & c4 )

Fill a range of LEDs with a smooth RGB gradient between four RGB colors.

See also
fill_gradient_RGB()
Parameters
ledsa pointer to the LED array to fill
numLedsthe number of LEDs to fill
c1the starting color in the gradient
c2the first middle color for the gradient
c3the second middle color for the gradient
c4the end color for the gradient

Definition at line 207 of file colorutils.cpp.

◆ fill_gradient_RGB() [4/4]

void fill_gradient_RGB ( CRGB * leds,
uint16_t startpos,
CRGB startcolor,
uint16_t endpos,
CRGB endcolor )

Fill a range of LEDs with a smooth RGB gradient between two RGB colors.

Unlike HSV, there is no "color wheel" in RGB space, and therefore there's only one "direction" for the gradient to go. This means there's no TGradientDirectionCode parameter for direction.

Parameters
ledsa pointer to the LED array to fill
startposthe starting position in the array
startcolorthe starting color for the gradient
endposthe ending position in the array
endcolorthe end color for the gradient

Definition at line 113 of file colorutils.cpp.

◆ fill_rainbow() [1/2]

void fill_rainbow ( struct CHSV * targetArray,
int numToFill,
uint8_t initialhue,
uint8_t deltahue = 5 )

Fill a range of LEDs with a rainbow of colors.

The colors making up the rainbow are at full saturation and full value (brightness).

Parameters
targetArraya pointer to the LED array to fill
numToFillthe number of LEDs to fill in the array
initialhuethe starting hue for the rainbow
deltahuehow many hue values to advance for each LED

Definition at line 57 of file colorutils.cpp.

◆ fill_rainbow() [2/2]

void fill_rainbow ( struct CRGB * targetArray,
int numToFill,
uint8_t initialhue,
uint8_t deltahue = 5 )

Fill a range of LEDs with a rainbow of colors.

The colors making up the rainbow are at full saturation and full value (brightness).

Parameters
targetArraya pointer to the LED array to fill
numToFillthe number of LEDs to fill in the array
initialhuethe starting hue for the rainbow
deltahuehow many hue values to advance for each LED

Definition at line 43 of file colorutils.cpp.

◆ fill_rainbow_circular() [1/2]

void fill_rainbow_circular ( struct CHSV * targetArray,
int numToFill,
uint8_t initialhue,
bool reversed = false )

Fill a range of LEDs with a rainbow of colors, so that the hues are continuous between the end of the strip and the beginning.

The colors making up the rainbow are at full saturation and full value (brightness).

Parameters
targetArraya pointer to the LED array to fill
numToFillthe number of LEDs to fill in the array
initialhuethe starting hue for the rainbow
reversedwhether to progress through the rainbow hues backwards

Definition at line 92 of file colorutils.cpp.

◆ fill_rainbow_circular() [2/2]

void fill_rainbow_circular ( struct CRGB * targetArray,
int numToFill,
uint8_t initialhue,
bool reversed = false )

Fill a range of LEDs with a rainbow of colors, so that the hues are continuous between the end of the strip and the beginning.

The colors making up the rainbow are at full saturation and full value (brightness).

Parameters
targetArraya pointer to the LED array to fill
numToFillthe number of LEDs to fill in the array
initialhuethe starting hue for the rainbow
reversedwhether to progress through the rainbow hues backwards

Definition at line 72 of file colorutils.cpp.

◆ fill_solid() [1/2]

void fill_solid ( struct CHSV * targetArray,
int numToFill,
const struct CHSV & color )

Fill a range of LEDs with a solid color.

Parameters
targetArraya pointer to the LED array to fill
numToFillthe number of LEDs to fill in the array
colorthe color to fill with

Definition at line 28 of file colorutils.cpp.

◆ fill_solid() [2/2]

void fill_solid ( struct CRGB * targetArray,
int numToFill,
const struct CRGB & color )

Fill a range of LEDs with a solid color.

Parameters
targetArraya pointer to the LED array to fill
numToFillthe number of LEDs to fill in the array
colorthe color to fill with

Definition at line 20 of file colorutils.cpp.

◆ HeatColor()

CRGB HeatColor ( uint8_t temperature)

Approximates a "black body radiation" spectrum for a given "heat" level.

This is useful for animations of "fire". Heat is specified as an arbitrary scale from 0 (cool) to 255 (hot). This is NOT a chromatically correct "black body radiation" spectrum, but it's surprisingly close, and it's fast and small.

Definition at line 505 of file colorutils.cpp.