FastLED  3.1
Color utility functions

A variety of functions for working with color, palletes, and leds. More...

Classes

union  TRGBGradientPaletteEntryUnion
 
class  CHSVPalette16
 
class  CHSVPalette256
 
class  CRGBPalette16
 
class  CHSVPalette32
 
class  CRGBPalette32
 
class  CRGBPalette256
 

Typedefs

typedef uint32_t TProgmemRGBPalette16[16]
 
typedef uint32_t TProgmemHSVPalette16[16]
 
typedef uint32_t TProgmemRGBPalette32[32]
 
typedef uint32_t TProgmemHSVPalette32[32]
 
typedef const uint8_t TProgmemRGBGradientPalette_byte
 
typedef const TProgmemRGBGradientPalette_byte * TProgmemRGBGradientPalette_bytes
 
typedef TProgmemRGBGradientPalette_bytes TProgmemRGBGradientPalettePtr
 
typedef uint8_t TDynamicRGBGradientPalette_byte
 
typedef const TDynamicRGBGradientPalette_byte * TDynamicRGBGradientPalette_bytes
 
typedef TDynamicRGBGradientPalette_bytes TDynamicRGBGradientPalettePtr
 

Enumerations

enum  TGradientDirectionCode { FORWARD_HUES, BACKWARD_HUES, SHORTEST_HUES, LONGEST_HUES }
 
enum  TBlendType { NOBLEND =0, LINEARBLEND =1 }
 

Functions

void fill_solid (struct CRGB *leds, int numToFill, const struct CRGB &color)
 fill_solid - fill a range of LEDs with a solid color Example: fill_solid( leds, NUM_LEDS, CRGB(50,0,200));
 
void fill_solid (struct CHSV *targetArray, int numToFill, const struct CHSV &hsvColor)
 fill_solid - fill a range of LEDs with a solid color Example: fill_solid( leds, NUM_LEDS, CRGB(50,0,200));
 
void fill_rainbow (struct CRGB *pFirstLED, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
 fill_rainbow - fill a range of LEDs with a rainbow of colors, at full saturation and full value (brightness)
 
void fill_rainbow (struct CHSV *targetArray, int numToFill, uint8_t initialhue, uint8_t deltahue=5)
 fill_rainbow - fill a range of LEDs with a rainbow of colors, at full saturation and full value (brightness)
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t startpos, CHSV startcolor, uint16_t endpos, CHSV endcolor, TGradientDirectionCode directionCode=SHORTEST_HUES)
 fill_gradient - fill an array of colors with a smooth HSV gradient between two specified HSV colors. More...
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t numLeds, const CHSV &c1, const CHSV &c2, TGradientDirectionCode directionCode=SHORTEST_HUES)
 
template<typename T >
void fill_gradient (T *targetArray, uint16_t numLeds, const CHSV &c1, const CHSV &c2, const CHSV &c3, TGradientDirectionCode directionCode=SHORTEST_HUES)
 
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)
 
void fill_gradient_RGB (CRGB *leds, uint16_t startpos, CRGB startcolor, uint16_t endpos, CRGB endcolor)
 
void fill_gradient_RGB (CRGB *leds, uint16_t numLeds, const CRGB &c1, const CRGB &c2)
 
void fill_gradient_RGB (CRGB *leds, uint16_t numLeds, const CRGB &c1, const CRGB &c2, const CRGB &c3)
 
void fill_gradient_RGB (CRGB *leds, uint16_t numLeds, const CRGB &c1, const CRGB &c2, const CRGB &c3, const CRGB &c4)
 
void fadeLightBy (CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
 
void fade_video (CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
 
void nscale8_video (CRGB *leds, uint16_t num_leds, uint8_t scale)
 
void fadeToBlackBy (CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
 
void fade_raw (CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
 
void nscale8 (CRGB *leds, uint16_t num_leds, uint8_t scale)
 
void fadeUsingColor (CRGB *leds, uint16_t numLeds, const CRGB &colormask)
 
CRGB blend (const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
 
CHSV blend (const CHSV &p1, const CHSV &p2, fract8 amountOfP2, TGradientDirectionCode directionCode=SHORTEST_HUES)
 
CRGBblend (const CRGB *src1, const CRGB *src2, CRGB *dest, uint16_t count, fract8 amountOfsrc2)
 
CHSVblend (const CHSV *src1, const CHSV *src2, CHSV *dest, uint16_t count, fract8 amountOfsrc2, TGradientDirectionCode directionCode=SHORTEST_HUES)
 
CRGBnblend (CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
 
CHSVnblend (CHSV &existing, const CHSV &overlay, fract8 amountOfOverlay, TGradientDirectionCode directionCode=SHORTEST_HUES)
 
void nblend (CRGB *existing, CRGB *overlay, uint16_t count, fract8 amountOfOverlay)
 
void nblend (CHSV *existing, CHSV *overlay, uint16_t count, fract8 amountOfOverlay, TGradientDirectionCode directionCode=SHORTEST_HUES)
 
void blur1d (CRGB *leds, uint16_t numLeds, fract8 blur_amount)
 
void blur2d (CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount)
 
void blurRows (CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount)
 
void blurColumns (CRGB *leds, uint8_t width, uint8_t height, fract8 blur_amount)
 
CRGB HeatColor (uint8_t temperature)
 
void UpscalePalette (const struct CRGBPalette16 &srcpal16, struct CRGBPalette256 &destpal256)
 
void UpscalePalette (const struct CHSVPalette16 &srcpal16, struct CHSVPalette256 &destpal256)
 
void UpscalePalette (const struct CRGBPalette16 &srcpal16, struct CRGBPalette32 &destpal32)
 
void UpscalePalette (const struct CHSVPalette16 &srcpal16, struct CHSVPalette32 &destpal32)
 
void UpscalePalette (const struct CRGBPalette32 &srcpal32, struct CRGBPalette256 &destpal256)
 
void UpscalePalette (const struct CHSVPalette32 &srcpal32, struct CHSVPalette256 &destpal256)
 
CRGB ColorFromPalette (const CRGBPalette16 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
 
CRGB ColorFromPalette (const TProgmemRGBPalette16 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
 
CRGB ColorFromPalette (const CRGBPalette256 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=NOBLEND)
 
CHSV ColorFromPalette (const CHSVPalette16 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
 
CHSV ColorFromPalette (const CHSVPalette256 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=NOBLEND)
 
CRGB ColorFromPalette (const CRGBPalette32 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
 
CRGB ColorFromPalette (const TProgmemRGBPalette32 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
 
CHSV ColorFromPalette (const CHSVPalette32 &pal, uint8_t index, uint8_t brightness=255, TBlendType blendType=LINEARBLEND)
 
template<typename PALETTE >
void fill_palette (CRGB *L, uint16_t N, uint8_t startIndex, uint8_t incIndex, const PALETTE &pal, uint8_t brightness, TBlendType blendType)
 
template<typename PALETTE >
void map_data_into_colors_through_palette (uint8_t *dataArray, uint16_t dataCount, CRGB *targetColorArray, const PALETTE &pal, uint8_t brightness=255, uint8_t opacity=255, TBlendType blendType=LINEARBLEND)
 
void nblendPaletteTowardPalette (CRGBPalette16 &currentPalette, CRGBPalette16 &targetPalette, uint8_t maxChanges=24)
 
uint8_t applyGamma_video (uint8_t brightness, float gamma)
 
CRGB applyGamma_video (const CRGB &orig, float gamma)
 
CRGB applyGamma_video (const CRGB &orig, float gammaR, float gammaG, float gammaB)
 
CRGBnapplyGamma_video (CRGB &rgb, float gamma)
 
CRGBnapplyGamma_video (CRGB &rgb, float gammaR, float gammaG, float gammaB)
 
void napplyGamma_video (CRGB *rgbarray, uint16_t count, float gamma)
 
void napplyGamma_video (CRGB *rgbarray, uint16_t count, float gammaR, float gammaG, float gammaB)
 

Detailed Description

A variety of functions for working with color, palletes, and leds.

Function Documentation

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

fill_gradient - fill an array of colors with a smooth HSV gradient between two specified HSV colors.

Since 'hue' is a value around a color wheel, there are always two ways to sweep from one hue to another. This function lets you specify which way you want the hue gradient to sweep around the color wheel:

FORWARD_HUES: hue always goes clockwise
BACKWARD_HUES: hue always goes counter-clockwise
SHORTEST_HUES: hue goes whichever way is shortest
LONGEST_HUES: hue goes whichever way is longest

The default is SHORTEST_HUES, as this is nearly always what is wanted.

fill_gradient can write the gradient colors EITHER (1) into an array of CRGBs (e.g., into leds[] array, or an RGB Palette) OR (2) into an array of CHSVs (e.g. an HSV 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 RGB array.

Definition at line 94 of file colorutils.h.