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

◆ fill_raw_2dnoise8() [1/3]

void fill_raw_2dnoise8 ( fl::u8 * pData,
int width,
int height,
fl::u8 octaves,
fl::q44 freq44,
fract8 amplitude,
int skip,
fl::u16 x,
fl::i16 scalex,
fl::u16 y,
fl::i16 scaley,
fl::u16 time )

Fill a 2D 8-bit buffer with noise, using inoise8()

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.
freq44starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave
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
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.
freq44starting octave frequency
amplitudenoise amplitude
skiphow many noise maps to skip over, incremented recursively per octave
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
Todo
Why isn't this declared in the header (noise.h)?

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

756 {
757 if(octaves > 1) {
758 fill_raw_2dnoise8(pData, width, height, octaves-1, freq44, amplitude, skip+1, x*freq44, freq44 * scalex, y*freq44, freq44 * scaley, time);
759 } else {
760 // amplitude is always 255 on the lowest level
761 amplitude=255;
762 }
763
764 scalex *= skip;
765 scaley *= skip;
766
767 fract8 invamp = 255-amplitude;
768 fl::u16 xx = x;
769 for(int i = 0; i < height; ++i, y+=scaley) {
770 fl::u8 *pRow = pData + (i*width);
771 xx = x;
772 for(int j = 0; j < width; ++j, xx+=scalex) {
773 fl::u8 noise_base = inoise8(xx,y,time);
774 noise_base = (0x80 & noise_base) ? (noise_base - 127) : (127 - noise_base);
775 noise_base = scale8(noise_base<<1,amplitude);
776 if(skip == 1) {
777 pRow[j] = scale8(pRow[j],invamp) + noise_base;
778 } else {
779 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
780 fl::u8 *pRow = pData + (ii*width);
781 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
782 pRow[jj] = scale8(pRow[jj],invamp) + noise_base;
783 }
784 }
785 }
786 }
787 }
788}
int y
Definition simple.h:93
int x
Definition simple.h:92
uint8_t octaves
void fill_raw_2dnoise8(fl::u8 *pData, int width, int height, fl::u8 octaves, fl::q44 freq44, fract8 amplitude, int skip, fl::u16 x, fl::i16 scalex, fl::u16 y, fl::i16 scaley, fl::u16 time) FL_NO_EXCEPT
Fill a 2D 8-bit buffer with noise, using inoise8()
fl::u8 inoise8(fl::u16 x, fl::u16 y, fl::u16 z) FL_NO_EXCEPT
8-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_2dnoise8(), FL_NO_EXCEPT, inoise8(), octaves, x, and y.

Referenced by fill_2dnoise16(), fill_2dnoise8(), fill_raw_2dnoise8(), and fill_raw_2dnoise8().

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