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

◆ fill_raw_2dnoise16()

void fill_raw_2dnoise16 ( uint16_t * pData,
int width,
int height,
uint8_t octaves,
q88 freq88,
fract16 amplitude,
int skip,
uint32_t x,
int32_t scalex,
uint32_t y,
int32_t scaley,
uint32_t time )

Fill a 2D 16-bit buffer with noise, using inoise16()

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.
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
freq88starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave

Definition at line 796 of file noise.cpp.

796 {
797 if(octaves > 1) {
798 fill_raw_2dnoise16(pData, width, height, octaves-1, freq88, amplitude, skip, x *freq88 , scalex *freq88, y * freq88, scaley * freq88, time);
799 } else {
800 // amplitude is always 255 on the lowest level
801 amplitude=65535;
802 }
803
804 scalex *= skip;
805 scaley *= skip;
806 fract16 invamp = 65535-amplitude;
807 for(int i = 0; i < height; i+=skip, y+=scaley) {
808 uint16_t *pRow = pData + (i*width);
809 for(int j = 0,xx=x; j < width; j+=skip, xx+=scalex) {
810 uint16_t noise_base = inoise16(xx,y,time);
811 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
812 noise_base = scale16(noise_base<<1, amplitude);
813 if(skip==1) {
814 pRow[j] = scale16(pRow[j],invamp) + noise_base;
815 } else {
816 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
817 uint16_t *pRow = pData + (ii*width);
818 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
819 pRow[jj] = scale16(pRow[jj],invamp) + noise_base;
820 }
821 }
822 }
823 }
824 }
825}
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
uint8_t octaves
uint16_t fract16
ANSI: unsigned _Fract.
Definition types.h:46
void fill_raw_2dnoise16(uint16_t *pData, int width, int height, uint8_t octaves, q88 freq88, fract16 amplitude, int skip, uint32_t x, int32_t scalex, uint32_t y, int32_t scaley, uint32_t time)
Fill a 2D 16-bit buffer with noise, using inoise16()
Definition noise.cpp:796
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z, uint32_t t)
16-bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:466
LIB8STATIC uint16_t scale16(uint16_t i, fract16 scale)
Scale a 16-bit unsigned value by an 16-bit value, which is treated as the numerator of a fraction who...
Definition scale8.h:540

References fill_raw_2dnoise16(), inoise16(), octaves, scale16(), x, and y.

Referenced by fill_raw_2dnoise16().

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