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

◆ spawn() [2/2]

void fl::Particles1d::Particle::spawn ( u16 numLeds)

Spawn with random position, velocity, color, and lifetime.

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

96 {
97 pos = random16(numLeds);
98 float speed = 0.02f + (random16(1000) / 1000.0f) * 0.13f;
99 baseVel = random8(2) ? speed : -speed;
100 baseColor = CHSV(random8(), random8(), 120 + random8(81));
101 lifetime = 4000 * (500 + random16(1000)) / 1000; // 2-6 seconds
103 active = true;
104}
uint16_t speed
Definition Noise.ino:66
fl::hsv8 CHSV
Definition chsv.h:11
LIB8STATIC fl::u16 random16() FL_NOEXCEPT
Generate a 16-bit random number.
Definition random8.h:63
LIB8STATIC fl::u8 random8() FL_NOEXCEPT
Generate an 8-bit random number.
Definition random8.h:53
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
CHSV baseColor
Base color (HSV) - saturation increases with age.
Definition particles.h:105
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
u32 lifetime
Lifespan in milliseconds.
Definition particles.h:107
u32 birthTime
Spawn timestamp (ms)
Definition particles.h:106

References active, baseColor, baseVel, birthTime, lifetime, fl::millis(), pos, random16(), random8(), and speed.

+ Here is the call graph for this function: