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

◆ fillnoise8()

void fl::NoisePalette::fillnoise8 ( )
private

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

142 {
143 // If we're running at a low "speed", some 8-bit artifacts become
144 // visible from frame-to-frame. In order to reduce this, we can do some
145 // fast data-smoothing. The amount of data smoothing we're doing depends
146 // on "speed".
147 u8 dataSmoothing = 0;
148 if (speed < 50) {
149 dataSmoothing = 200 - (speed * 4);
150 }
151
152 for (u16 i = 0; i < width; i++) {
153 int ioffset = scale * i;
154 for (u16 j = 0; j < height; j++) {
155 int joffset = scale * j;
156
157 u8 data = inoise8(mX + ioffset, mY + joffset, mZ);
158
159 // The range of the inoise8 function is roughly 16-238.
160 // These two operations expand those values out to roughly
161 // 0..255 You can comment them out if you want the raw noise
162 // data.
163 data = qsub8(data, 16);
164 data = qadd8(data, scale8(data, 39));
165
166 if (dataSmoothing) {
167 u8 olddata = noise[i * height + j];
168 u8 newdata = scale8(olddata, dataSmoothing) +
169 scale8(data, 256 - dataSmoothing);
170 data = newdata;
171 }
172
173 noise[i * height + j] = data;
174 }
175 }
176
177 mZ += speed;
178
179 // apply slow drift to X and Y, just for visual variation.
180 mX += speed / 8;
181 mY -= speed / 16;
182}
fl::vector_psram< u8 > noise
fl::u8 inoise8(fl::u16 x, fl::u16 y, fl::u16 z)
unsigned char u8
Definition stdint.h:131

References height, inoise8(), mX, mY, mZ, noise, scale, speed, and width.

Referenced by draw().

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