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

Function drawMatrixRain

examples/Audio/advanced/advanced.h:382–405  ·  view source on GitHub ↗

Visualization: Matrix Rain

Source from the content-addressed store, hash-verified

380
381// Visualization: Matrix Rain
382void drawMatrixRain(float peak) {
383 // Shift everything down
384 for (int x = 0; x < WIDTH; x++) {
385 for (int y = HEIGHT - 1; y > 0; y--) {
386 int currentIndex = xyMap(x, y);
387 int aboveIndex = xyMap(x, y - 1);
388 if (currentIndex >= 0 && currentIndex < NUM_LEDS &&
389 aboveIndex >= 0 && aboveIndex < NUM_LEDS) {
390 leds[currentIndex] = leds[aboveIndex];
391 leds[currentIndex].fadeToBlackBy(40);
392 }
393 }
394 }
395
396 // Add new drops based on audio
397 int numDrops = peak * WIDTH * audioGain.value() * autoGainValue;
398 for (int i = 0; i < numDrops; i++) {
399 int x = random(WIDTH);
400 int ledIndex = xyMap(x, 0);
401 if (ledIndex >= 0 && ledIndex < NUM_LEDS) {
402 leds[ledIndex] = CHSV(96, 255, 255); // Green
403 }
404 }
405}
406
407// Visualization: Fire Effect (simplified for WebAssembly)
408void drawFireEffect(float peak) {

Callers 1

loopFunction · 0.85

Calls 2

randomClass · 0.50
valueMethod · 0.45

Tested by

no test coverage detected