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

Function triggerRipple

examples/Fx/FxWave2d/wavefx.cpp:155–173  ·  view source on GitHub ↗

Create a ripple effect at a random position within the central area of the display

Source from the content-addressed store, hash-verified

153
154// Create a ripple effect at a random position within the central area of the display
155void triggerRipple() {
156 // Define a margin percentage to keep ripples away from the edges
157 float perc = .15f;
158
159 // Calculate the boundaries for the ripple (15% from each edge)
160 uint8_t min_x = perc * WIDTH; // Left boundary
161 uint8_t max_x = (1 - perc) * WIDTH; // Right boundary
162 uint8_t min_y = perc * HEIGHT; // Top boundary
163 uint8_t max_y = (1 - perc) * HEIGHT; // Bottom boundary
164
165 // Generate a random position within these boundaries
166 int x = random(min_x, max_x);
167 int y = random(min_y, max_y);
168
169 // Set a wave peak at this position in both wave layers
170 // The value 1.0 represents the maximum height of the wave
171 waveFxLower.setf(x, y, 1); // Create ripple in lower layer
172 waveFxUpper.setf(x, y, 1); // Create ripple in upper layer
173}
174
175// Create a fancy cross-shaped effect that expands from the center
176void applyFancyEffect(uint32_t now, bool button_active) {

Callers 2

processAutoTriggerFunction · 0.70
wavefx_loopFunction · 0.70

Calls 2

randomClass · 0.50
setfMethod · 0.45

Tested by

no test coverage detected