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 751 of file noise.cpp.

751 {
752 if(octaves > 1) {
753 fill_raw_2dnoise16(pData, width, height, octaves-1, freq88, amplitude, skip, x *freq88 , scalex *freq88, y * freq88, scaley * freq88, time);
754 } else {
755 // amplitude is always 255 on the lowest level
756 amplitude=65535;
757 }
758
759 scalex *= skip;
760 scaley *= skip;
761 fract16 invamp = 65535-amplitude;
762 for(int i = 0; i < height; i+=skip, y+=scaley) {
763 uint16_t *pRow = pData + (i*width);
764 for(int j = 0,xx=x; j < width; j+=skip, xx+=scalex) {
765 uint16_t noise_base = inoise16(xx,y,time);
766 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
767 noise_base = scale16(noise_base<<1, amplitude);
768 if(skip==1) {
769 pRow[j] = scale16(pRow[j],invamp) + noise_base;
770 } else {
771 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
772 uint16_t *pRow = pData + (ii*width);
773 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
774 pRow[jj] = scale16(pRow[jj],invamp) + noise_base;
775 }
776 }
777 }
778 }
779 }
780}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint8_t octaves
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:751
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:420
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:551
u16 fract16
ANSI: unsigned _Fract.
Definition int.h:59

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: