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

◆ fill_raw_2dnoise8() [1/3]

void fill_raw_2dnoise8 ( uint8_t * pData,
int width,
int height,
uint8_t octaves,
q44 freq44,
fract8 amplitude,
int skip,
uint16_t x,
int16_t scalex,
uint16_t y,
int16_t scaley,
uint16_t time )

Fill a 2D 8-bit buffer with noise, using inoise8()

Parameters
pDatathe array of data to fill with noise values
widththe width of the 2D buffer
heightthe height of the 2D buffer
octavesthe number of octaves to use for noise. More octaves = more noise.
freq44starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave
xx-axis coordinate on noise map (1D)
scalexthe scale (distance) between x points when filling in noise
yy-axis coordinate on noise map (2D)
scaleythe scale (distance) between y points when filling in noise
timethe time position for the noise field
pDatathe array of data to fill with noise values
widththe width of the 2D buffer
heightthe height of the 2D buffer
octavesthe number of octaves to use for noise. More octaves = more noise.
freq44starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave
xx-axis coordinate on noise map (1D)
scalexthe scale (distance) between x points when filling in noise
yy-axis coordinate on noise map (2D)
scaleythe scale (distance) between y points when filling in noise
timethe time position for the noise field
Todo
Why isn't this declared in the header (noise.h)?

Definition at line 758 of file noise.cpp.

758 {
759 if(octaves > 1) {
760 fill_raw_2dnoise8(pData, width, height, octaves-1, freq44, amplitude, skip+1, x*freq44, freq44 * scalex, y*freq44, freq44 * scaley, time);
761 } else {
762 // amplitude is always 255 on the lowest level
763 amplitude=255;
764 }
765
766 scalex *= skip;
767 scaley *= skip;
768
769 fract8 invamp = 255-amplitude;
770 uint16_t xx = x;
771 for(int i = 0; i < height; ++i, y+=scaley) {
772 uint8_t *pRow = pData + (i*width);
773 xx = x;
774 for(int j = 0; j < width; ++j, xx+=scalex) {
775 uint8_t noise_base = inoise8(xx,y,time);
776 noise_base = (0x80 & noise_base) ? (noise_base - 127) : (127 - noise_base);
777 noise_base = scale8(noise_base<<1,amplitude);
778 if(skip == 1) {
779 pRow[j] = scale8(pRow[j],invamp) + noise_base;
780 } else {
781 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
782 uint8_t *pRow = pData + (ii*width);
783 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
784 pRow[jj] = scale8(pRow[jj],invamp) + noise_base;
785 }
786 }
787 }
788 }
789 }
790}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
uint8_t octaves
uint8_t fract8
ANSI: unsigned short _Fract.
Definition types.h:36
void fill_raw_2dnoise8(uint8_t *pData, int width, int height, uint8_t octaves, q44 freq44, fract8 amplitude, int skip, uint16_t x, int16_t scalex, uint16_t y, int16_t scaley, uint16_t time)
Fill a 2D 8-bit buffer with noise, using inoise8()
Definition noise.cpp:758
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 fill_raw_2dnoise8(), inoise8(), octaves, scale8(), x, and y.

Referenced by fill_2dnoise16(), fill_2dnoise8(), fill_raw_2dnoise8(), and fill_raw_2dnoise8().

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