FastLED 3.9.7
Loading...
Searching...
No Matches
Color Palettes

Detailed Description

Functions and class definitions for color palettes.

RGB palettes map an 8-bit value (0-255) to an RGB color.

You can create any color palette you wish; a couple of starters are provided: ForestColors_p, CloudColors_p, LavaColors_p, OceanColors_p, RainbowColors_p, and RainbowStripeColors_p.

Palettes come in the traditional 256-entry variety, which take up 768 bytes of RAM, and lightweight 16-entry varieties. The 16-entry variety automatically interpolates between its entries to produce a full 256-element color map, but at a cost of only 48 bytes of RAM.

Basic operation is like this (using the 16-entry variety):

  1. Declare your palette storage:
    CRGBPalette16 myPalette;
    RGB color palette with 16 discrete values.
    Definition colorutils.h:997
  2. Fill myPalette with your own 16 colors, or with a preset color scheme. You can specify your 16 colors a variety of ways:

    CRGBPalette16 myPalette(
    0x100000,
    0x200000,
    0x400000,
    0x800000,
    CHSV( 30,255,255),
    CHSV( 50,255,255),
    CHSV( 70,255,255),
    CHSV( 90,255,255)
    );
    Representation of an HSV pixel (hue, saturation, value (aka brightness)).
    Definition chsv.h:16
    @ Purple
    Definition crgb.h:607
    @ Green
    Definition crgb.h:544
    @ Blue
    Definition crgb.h:498
    @ Red
    Definition crgb.h:608
    @ Black
    Definition crgb.h:496
    @ Yellow
    Definition crgb.h:634

    Or you can initiaize your palette with a preset color scheme:

    #define RainbowStripesColors_p
    Alias of RainbowStripeColors_p.
  3. Any time you want to set a pixel to a color from your palette, use ColorFromPalette() as shown:

    uint8_t index = /* any value 0-255 */;
    leds[i] = ColorFromPalette(myPalette, index);
    CRGB ColorFromPalette(const CRGBPalette16 &pal, uint8_t index, uint8_t brightness, TBlendType blendType)
    Get a color from a palette.

    Even though your palette has only 16 explicily defined entries, you can use an "index" from 0-255. The 16 explicit palette entries will be spread evenly across the 0-255 range, and the intermedate values will be RGB-interpolated between adjacent explicit entries.

    It's easier to use than it sounds.

Topics

 Palette Classes
 Class definitions for color palettes.
 
 Palette Color Functions
 Functions to retrieve smooth color data from palettes
 
 Palette Upscaling Functions
 Functions to upscale palettes from one type to another.
 
 Predefined Color Palettes
 Stock color palettes, only included when used.