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

◆ fillnoise8()

void fl::NoisePalette::fillnoise8 ( )
private

Definition at line 142 of file noisepalette.cpp.

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 uint8_t dataSmoothing = 0;
148 if (speed < 50) {
149 dataSmoothing = 200 - (speed * 4);
150 }
151
152 for (uint16_t i = 0; i < width; i++) {
153 int ioffset = scale * i;
154 for (uint16_t j = 0; j < height; j++) {
155 int joffset = scale * j;
156
157 uint8_t 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 uint8_t olddata = noise.get()[i * height + j];
168 uint8_t newdata = scale8(olddata, dataSmoothing) +
169 scale8(data, 256 - dataSmoothing);
170 data = newdata;
171 }
172
173 noise.get()[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::scoped_array< uint8_t > noise
LIB8STATIC_ALWAYS_INLINE uint8_t qadd8(uint8_t i, uint8_t j)
Add one byte to another, saturating at 0xFF.
Definition math8.h:31
LIB8STATIC_ALWAYS_INLINE uint8_t qsub8(uint8_t i, uint8_t j)
Subtract one byte from another, saturating at 0x00.
Definition math8.h:103
uint8_t inoise8(uint16_t x, uint16_t y, uint16_t z)
8-Bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:616
LIB8STATIC_ALWAYS_INLINE uint8_t scale8(uint8_t i, fract8 scale)
Scale one byte by a second one, which is treated as the numerator of a fraction whose denominator is ...
Definition scale8.h:34

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

Referenced by draw().

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