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

◆ fill_2dnoise16()

void fill_2dnoise16 ( CRGB * leds,
int width,
int height,
bool serpentine,
uint8_t octaves,
uint32_t x,
int xscale,
uint32_t y,
int yscale,
uint32_t time,
uint8_t hue_octaves,
uint16_t hue_x,
int hue_xscale,
uint16_t hue_y,
uint16_t hue_yscale,
uint16_t hue_time,
bool blend,
uint16_t 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 964 of file noise.cpp.

966 {
967
968 VARIABLE_LENGTH_ARRAY(uint8_t, V, height*width);
969 VARIABLE_LENGTH_ARRAY(uint8_t, H, height*width);
970
971 memset(V,0,height*width);
972 memset(H,0,height*width);
973
974 fill_raw_2dnoise16into8((uint8_t*)V,width,height,octaves,q44(2,0),171,1,x,xscale,y,yscale,time);
975 // fill_raw_2dnoise16into8((uint8_t*)V,width,height,octaves,x,xscale,y,yscale,time);
976 // fill_raw_2dnoise8((uint8_t*)V,width,height,hue_octaves,x,xscale,y,yscale,time);
977 fill_raw_2dnoise8((uint8_t*)H,width,height,hue_octaves,hue_x,hue_xscale,hue_y,hue_yscale,hue_time);
978
979
980 int w1 = width-1;
981 int h1 = height-1;
982 hue_shift >>= 8;
983
984 for(int i = 0; i < height; ++i) {
985 int wb = i*width;
986 for(int j = 0; j < width; ++j) {
987 CRGB led(CHSV(hue_shift + (H[(h1-i)*width + (w1-j)]), 196, V[i*width + j]));
988
989 int pos = j;
990 if(serpentine && (i & 0x1)) {
991 pos = w1-j;
992 }
993
994 if(blend) {
995 leds[wb+pos] >>= 1; leds[wb+pos] += (led>>=1);
996 } else {
997 leds[wb+pos] = led;
998 }
999 }
1000 }
1001}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
uint8_t pos
Definition Blur.ino:11
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
uint8_t hue_octaves
int yscale
uint8_t octaves
int xscale
uint32_t hue_time
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)
Computes a new color blended some fraction of the way between two other colors.
qfx< uint8_t, 4, 4 > q44
A 4.4 integer (4 bits integer, 4 bits fraction)
Definition qfx.h:48
void fill_raw_2dnoise16into8(uint8_t *pData, int width, int height, uint8_t octaves, q44 freq44, fract8 amplitude, int skip, uint32_t x, int32_t scalex, uint32_t y, int32_t scaley, uint32_t time)
Fill a 2D 8-bit buffer with noise, using inoise16()
Definition noise.cpp:834
void fill_raw_2dnoise8(uint8_t *pData, int width, int height, uint8_t octaves, q44 freq44, fract8 amplitude, int skip, uint16_t x, int16_t scalex, uint16_t y, int16_t scaley, uint16_t time)
Fill a 2D 8-bit buffer with noise, using inoise8()
Definition noise.cpp:758
#define VARIABLE_LENGTH_ARRAY(TYPE, NAME, SIZE)
Definition noise.cpp:19
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54

References blend(), fill_raw_2dnoise16into8(), fill_raw_2dnoise8(), hue_octaves, hue_time, leds, octaves, pos, VARIABLE_LENGTH_ARRAY, x, xscale, y, and yscale.

Referenced by loop().

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