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

◆ mapNoiseToLEDsUsingPalette()

void fl::NoisePalette::mapNoiseToLEDsUsingPalette ( fl::span< CRGB > leds)

Definition at line 109 of file noisepalette.cpp.hpp.

109 {
110 static u8 ihue = 0; // okay static in header
111
112 for (u16 i = 0; i < width; i++) {
113 for (u16 j = 0; j < height; j++) {
114 // We use the value at the (i,j) coordinate in the noise
115 // array for our brightness, and the flipped value from (j,i)
116 // for our pixel's index into the color palette.
117
118 u8 index = noise[i * height + j];
119 u8 bri = noise[j * width + i];
120
121 // if this palette is a 'loop', add a slowly-changing base value
122 if (colorLoop) {
123 index += ihue;
124 }
125
126 // brighten up, as the color palette itself often contains the
127 // light/dark dynamic range desired
128 if (bri > 127) {
129 bri = 255;
130 } else {
131 bri = dim8_raw(bri * 2);
132 }
133
134 CRGB color = ColorFromPalette(currentPalette, index, bri);
135 leds[XY(i, j)] = color;
136 }
137 }
138
139 ihue += 1;
140}
fl::CRGB leds[NUM_LEDS]
CRGBPalette16 currentPalette
fl::vector_psram< u8 > noise
u16 XY(u8 x, u8 y) const
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:15
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType)

References fl::ColorFromPalette(), colorLoop, currentPalette, height, leds, noise, width, and XY().

Referenced by draw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: