MCPcopy Create free account
hub / github.com/FastLED/FastLED / mapNoiseToLEDsUsingPalette

Method mapNoiseToLEDsUsingPalette

src/fl/fx/2d/noisepalette.cpp.hpp:109–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

107}
108
109void NoisePalette::mapNoiseToLEDsUsingPalette(fl::span<CRGB> leds) {
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}
141
142void NoisePalette::fillnoise8() {
143 // If we're running at a low "speed", some 8-bit artifacts become

Callers

nothing calls this directly

Calls 2

ColorFromPaletteFunction · 0.85
XYFunction · 0.50

Tested by

no test coverage detected