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

◆ fillnoise8()

void fl::NoisePalette::fillnoise8 ( )
private

Definition at line 141 of file noisepalette.cpp.

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

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: