FastLED 3.9.15
Loading...
Searching...
No Matches

◆ CRGBPalette32() [18/18]

CRGBPalette32::CRGBPalette32 ( TProgmemRGBGradientPalette_bytes progpal)
inline

Creates a palette from a gradient palette in PROGMEM.

Gradient palettes are loaded into CRGBPalettes in such a way that, if possible, every color represented in the gradient palette is also represented in the CRGBPalette.

For example, consider a gradient palette that is all black except for a single, one-element-wide (1/256th!) spike of red in the middle:

0, 0,0,0
124, 0,0,0
125, 255,0,0 // one 1/256th-palette-wide red stripe
126, 0,0,0
255, 0,0,0

A naive conversion of this 256-element palette to a 16-element palette might accidentally completely eliminate the red spike, rendering the palette completely black.

However, the conversions provided here would attempt to include a the red stripe in the output, more-or-less as faithfully as possible. So in this case, the resulting CRGBPalette16 palette would have a red stripe in the middle which was 1/16th of a palette wide – the narrowest possible in a CRGBPalette16.

This means that the relative width of stripes in a CRGBPalette16 will be, by definition, different from the widths in the gradient palette. This code attempts to preserve "all the colors", rather than the exact stripe widths at the expense of dropping some colors.

Definition at line 1649 of file colorutils.h.

1650 {
1651 *this = progpal;
1652 }