MCPcopy Create free account
hub / github.com/FastLED/FastLED / fill_raw_2dnoise16into8

Function fill_raw_2dnoise16into8

src/noise.cpp.hpp:794–825  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

792fl::i32 nmax=0;
793
794void 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) {
795 if(octaves > 1) {
796 fill_raw_2dnoise16into8(pData, width, height, octaves-1, freq44, amplitude, skip+1, x*freq44, scalex *freq44, y*freq44, scaley * freq44, time);
797 } else {
798 // amplitude is always 255 on the lowest level
799 amplitude=255;
800 }
801
802 scalex *= skip;
803 scaley *= skip;
804 fl::u32 xx;
805 fract8 invamp = 255-amplitude;
806 for(int i = 0; i < height; i+=skip, y+=scaley) {
807 fl::u8 *pRow = pData + (i*width);
808 xx = x;
809 for(int j = 0; j < width; j+=skip, xx+=scalex) {
810 fl::u16 noise_base = inoise16(xx,y,time);
811 noise_base = (0x8000 & noise_base) ? noise_base - (32767) : 32767 - noise_base;
812 noise_base = scale8(noise_base>>7,amplitude);
813 if(skip==1) {
814 pRow[j] = qadd8(scale8(pRow[j],invamp),noise_base);
815 } else {
816 for(int ii = i; ii<(i+skip) && ii<height; ++ii) {
817 fl::u8 *pRow = pData + (ii*width);
818 for(int jj=j; jj<(j+skip) && jj<width; ++jj) {
819 pRow[jj] = scale8(pRow[jj],invamp) + noise_base;
820 }
821 }
822 }
823 }
824 }
825}
826
827void fill_raw_2dnoise16into8(fl::u8 *pData, int width, int height, fl::u8 octaves, fl::u32 x, int scalex, fl::u32 y, int scaley, fl::u32 time) {
828 fill_raw_2dnoise16into8(pData, width, height, octaves, fl::q44(2,0), 171, 1, x, scalex, y, scaley, time);

Callers 1

fill_2dnoise16Function · 0.85

Calls 2

inoise16Function · 0.85
scale8Function · 0.50

Tested by

no test coverage detected