FastLED 3.10.8
Loading...
Searching...
No Matches

◆ fill_raw_2dnoise16()

void fill_raw_2dnoise16 ( fl::u16 * pData,
int width,
int height,
fl::u8 octaves,
fl::q88 freq88,
fract16 amplitude,
int skip,
fl::u32 x,
fl::i32 scalex,
fl::u32 y,
fl::i32 scaley,
fl::u32 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 794 of file noise.cpp.hpp.

794 {
795 if(octaves > 1) {
796 fill_raw_2dnoise16(pData, width, height, octaves-1, freq88, amplitude, skip, x *freq88 , scalex *freq88, y * freq88, scaley * freq88, time);
797 } else {
798 // amplitude is always 255 on the lowest level
799 amplitude=65535;
800 }
801
802 scalex *= skip;
803 scaley *= skip;
804 fract16 invamp = 65535-amplitude;
805 for(int i = 0; i < height; i+=skip, y+=scaley) {
806 fl::u16 *pRow = pData + (i*width);
807 for(int j = 0,xx=x; j < width; j+=skip, xx+=scalex) {
808 fl::u16 noise_base = inoise16(xx,y,time);
809 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
810 noise_base = scale16(noise_base<<1, amplitude);
811 if(skip==1) {
812 pRow[j] = scale16(pRow[j],invamp) + noise_base;
813 } else {
814 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
815 fl::u16 *pRow = pData + (ii*width);
816 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
817 pRow[jj] = scale16(pRow[jj],invamp) + noise_base;
818 }
819 }
820 }
821 }
822 }
823}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint8_t octaves
void fill_raw_2dnoise16(fl::u16 *pData, int width, int height, fl::u8 octaves, fl::q88 freq88, fract16 amplitude, int skip, fl::u32 x, fl::i32 scalex, fl::u32 y, fl::i32 scaley, fl::u32 time) FL_NO_EXCEPT
Fill a 2D 16-bit buffer with noise, using inoise16()
fl::u16 inoise16(fl::u32 x, fl::u32 y, fl::u32 z, fl::u32 t) FL_NO_EXCEPT
16-bit, fixed point implementation of Perlin's noise.
u8 u8 height
Definition blur.h:186
u8 width
Definition blur.h:186
u16 fract16
ANSI: unsigned _Fract.
Definition stdint.h:170

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

Referenced by fill_raw_2dnoise16().

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