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

770 {
771 if(octaves > 1) {
772 fill_raw_2dnoise16(pData, width, height, octaves-1, freq88, amplitude, skip, x *freq88 , scalex *freq88, y * freq88, scaley * freq88, time);
773 } else {
774 // amplitude is always 255 on the lowest level
775 amplitude=65535;
776 }
777
778 scalex *= skip;
779 scaley *= skip;
780 fract16 invamp = 65535-amplitude;
781 for(int i = 0; i < height; i+=skip, y+=scaley) {
782 uint16_t *pRow = pData + (i*width);
783 for(int j = 0,xx=x; j < width; j+=skip, xx+=scalex) {
784 uint16_t noise_base = inoise16(xx,y,time);
785 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
786 noise_base = scale16(noise_base<<1, amplitude);
787 if(skip==1) {
788 pRow[j] = scale16(pRow[j],invamp) + noise_base;
789 } else {
790 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
791 uint16_t *pRow = pData + (ii*width);
792 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
793 pRow[jj] = scale16(pRow[jj],invamp) + noise_base;
794 }
795 }
796 }
797 }
798 }
799}
int y
Definition Audio.ino:72
int x
Definition Audio.ino:71
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:770
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:440
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:546

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: