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

◆ fill_raw_2dnoise16into8() [1/2]

void fill_raw_2dnoise16into8 ( fl::u8 * pData,
int width,
int height,
fl::u8 octaves,
fl::q44 freq44,
fract8 amplitude,
int skip,
fl::u32 x,
fl::i32 scalex,
fl::u32 y,
fl::i32 scaley,
fl::u32 time )

Fill a 2D 8-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
freq44starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave

Definition at line 832 of file noise.cpp.hpp.

832 {
833 if(octaves > 1) {
834 fill_raw_2dnoise16into8(pData, width, height, octaves-1, freq44, amplitude, skip+1, x*freq44, scalex *freq44, y*freq44, scaley * freq44, time);
835 } else {
836 // amplitude is always 255 on the lowest level
837 amplitude=255;
838 }
839
840 scalex *= skip;
841 scaley *= skip;
842 fl::u32 xx;
843 fract8 invamp = 255-amplitude;
844 for(int i = 0; i < height; i+=skip, y+=scaley) {
845 fl::u8 *pRow = pData + (i*width);
846 xx = x;
847 for(int j = 0; j < width; j+=skip, xx+=scalex) {
848 fl::u16 noise_base = inoise16(xx,y,time);
849 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
850 noise_base = scale8(noise_base>>7,amplitude);
851 if(skip==1) {
852 pRow[j] = qadd8(scale8(pRow[j],invamp),noise_base);
853 } else {
854 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
855 fl::u8 *pRow = pData + (ii*width);
856 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
857 pRow[jj] = scale8(pRow[jj],invamp) + noise_base;
858 }
859 }
860 }
861 }
862 }
863}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint8_t octaves
void fill_raw_2dnoise16into8(fl::u8 *pData, int width, int height, fl::u8 octaves, fl::q44 freq44, fract8 amplitude, int skip, fl::u32 x, fl::i32 scalex, fl::u32 y, fl::i32 scaley, fl::u32 time) FL_NO_EXCEPT
Fill a 2D 8-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.
unsigned char u8
Definition stdint.h:131
u8 u8 height
Definition blur.h:186
u8 fract8
Fixed-Point Fractional Types.
Definition stdint.h:160
u8 width
Definition blur.h:186

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

Referenced by fill_2dnoise16(), fill_raw_2dnoise16into8(), and fill_raw_2dnoise16into8().

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