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

◆ fillnoise8()

void fl::NoisePalette::fillnoise8 ( )
private

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

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

References fl::FL_NO_EXCEPT, 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: