FastLED 3.10.8
Loading...
Searching...
No Matches

◆ mapNoiseToLEDsUsingPalette()

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

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

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

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

Referenced by draw().

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