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

◆ update()

void fl::Particles1d::Particle::update ( u32 now,
u16 numLeds,
float speedMultiplier,
bool cyclical )

Update position based on velocity × power.

Definition at line 115 of file particles.cpp.hpp.

115 {
116 if (!active) return;
117 float power = getPower(now);
118 if (power <= 0.0f) {
119 active = false;
120 return;
121 }
122
123 pos += baseVel * power * speedMultiplier;
124
125 if (cyclical) {
126 // Wrap around (cyclical)
127 while (pos >= numLeds) pos -= numLeds;
128 while (pos < 0) pos += numLeds;
129 } else {
130 // Stop at edges
131 if (pos >= numLeds || pos < 0) {
132 active = false;
133 }
134 }
135}
float getPower(u32 now) const
bool active
Active flag (false = available for reuse)
Definition particles.h:108
float pos
Position (floating point for sub-pixel rendering)
Definition particles.h:103
float baseVel
Base velocity (actual velocity = baseVel × power)
Definition particles.h:104

References active, baseVel, getPower(), and pos.

+ Here is the call graph for this function: