FastLED 3.9.15
Loading...
Searching...
No Matches

◆ fill_2dnoise16()

void fill_2dnoise16 ( CRGB * leds,
int width,
int height,
bool serpentine,
fl::u8 octaves,
fl::u32 x,
int xscale,
fl::u32 y,
int yscale,
fl::u32 time,
fl::u8 hue_octaves,
fl::u16 hue_x,
int hue_xscale,
fl::u16 hue_y,
fl::u16 hue_yscale,
fl::u16 hue_time,
bool blend,
fl::u16 hue_shift = 0 )

Fill an LED matrix with random colors, using 16-bit noise.

Parameters
ledspointer to LED array
widththe width of the LED matrix
heightthe height of the LED matrix
serpentinewhether the matrix is laid out in a serpentine pattern (alternating left/right directions per row)
octavesthe number of octaves to use for value (brightness) noise
xx-axis coordinate on noise map for value (brightness) noise
xscalethe scale (distance) between x points when filling in value (brightness) noise
yy-axis coordinate on noise map for value (brightness) noise
yscalethe scale (distance) between y points when filling in value (brightness) noise
timethe time position for the value (brightness) noise field
hue_octavesthe number of octaves to use for color hue noise
hue_xx-axis coordinate on noise map for color hue noise
hue_xscalethe scale (distance) between x points when filling in color hue noise
hue_yy-axis coordinate on noise map for color hue noise.
hue_yscalethe scale (distance) between y points when filling in color hue noise
hue_timethe time position for the color hue noise field
blendif true, will blend the newly generated LED values into the array. If false, will overwrite the array values directly.
hue_shifthow much to shift the final hues by for every LED

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

924 {
925
926 FASTLED_STACK_ARRAY(fl::u8, V, height*width);
927 FASTLED_STACK_ARRAY(fl::u8, H, height*width);
928
929 fl::memset(V,0,height*width);
930 fl::memset(H,0,height*width);
931
932 fill_raw_2dnoise16into8((fl::u8*)V,width,height,octaves,fl::q44(2,0),171,1,x,xscale,y,yscale,time);
933 // fill_raw_2dnoise16into8((uint8_t*)V,width,height,octaves,x,xscale,y,yscale,time);
934 // fill_raw_2dnoise8((uint8_t*)V,width,height,hue_octaves,x,xscale,y,yscale,time);
935 fill_raw_2dnoise8((fl::u8*)H,width,height,hue_octaves,hue_x,hue_xscale,hue_y,hue_yscale,hue_time);
936
937
938 int w1 = width-1;
939 int h1 = height-1;
940 hue_shift >>= 8;
941
942 for(int i = 0; i < height; ++i) {
943 int wb = i*width;
944 for(int j = 0; j < width; ++j) {
945 CRGB led(CHSV(hue_shift + (H[(h1-i)*width + (w1-j)]), 196, V[i*width + j]));
946
947 int pos = j;
948 if(serpentine && (i & 0x1)) {
949 pos = w1-j;
950 }
951
952 if(blend) {
953 leds[wb+pos] >>= 1; leds[wb+pos] += (led>>=1);
954 } else {
955 leds[wb+pos] = led;
956 }
957 }
958 }
959}
fl::CRGB leds[NUM_LEDS]
int y
Definition simple.h:93
int x
Definition simple.h:92
uint8_t pos
Definition Blur.ino:11
uint8_t hue_octaves
int yscale
uint8_t octaves
int xscale
uint32_t hue_time
static const int H
Definition PerfDisc.ino:20
#define FASTLED_STACK_ARRAY(TYPE, NAME, SIZE)
Stack-allocated array with automatic zero-initialization.
Definition alloca.h:32
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
qfx< u8, 4, 4 > q44
A 4.4 integer (4 bits integer, 4 bits fraction)
Definition qfx.h:45
fl::hsv8 CHSV
Definition chsv.h:11
fl::CRGB CRGB
Definition crgb.h:25
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()
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()
unsigned char u8
Definition stdint.h:131
u8 u8 height
Definition blur.h:186
void * memset(void *s, int c, size_t n) FL_NOEXCEPT
u8 width
Definition blur.h:186

References blend(), FASTLED_STACK_ARRAY, fill_raw_2dnoise16into8(), fill_raw_2dnoise8(), H, hue_octaves, hue_time, leds, fl::memset(), octaves, pos, x, xscale, y, and yscale.

Referenced by loop().

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