20 if (context.leds.empty() ||
mNumLeds == 0)
return;
22 u32 now = context.now;
32 for (
size_t i = 0; i <
mParticles.size(); i++) {
44 for (
size_t i = 0; i <
mParticles.size(); i++) {
54 for (
size_t i = 1; i <
mParticles.size(); i++) {
127 while (
pos >= numLeds)
pos -= numLeds;
128 while (
pos < 0)
pos += numLeds;
131 if (
pos >= numLeds ||
pos < 0) {
140 if (power <= 0.0f)
return;
149 float frac =
pos - i;
150 if (i >= 0 && i < (
int)numLeds)
152 if (i + 1 >= 0 && i + 1 < (
int)numLeds && frac > 0)
~Particles1d() FL_NOEXCEPT
void setSpeed(float speed)
Set speed multiplier (1.0 = normal, >1.0 = faster, <1.0 = slower)
fl::vector< Particle > mParticles
Particle pool (oldest particle reused when full)
void setCyclical(bool cyclical)
Set cyclical mode (true = wrap around, false = stop at edges)
u8 mFadeRate
Fade amount per frame (0-255, higher = shorter trails)
Particles1d(u16 num_leds, u8 max_particles=10, u8 fade_rate=2)
void setFadeRate(u8 fade_rate)
Set fade rate for trails (0-255, higher = shorter trails)
u8 mOverdrawCount
Number of update/draw cycles per frame (higher = smoother trails, more CPU)
u16 mLifetimeMs
Average particle lifetime in milliseconds.
void setOverdrawCount(u8 count)
Set overdraw count (higher = smoother trails, more CPU)
float mSpeedMultiplier
Global speed multiplier (1.0 = normal, >1.0 = faster, <1.0 = slower)
bool mCyclical
Wrap mode: true = wrap around, false = stop at edges.
void spawnRandomParticle()
Spawn a particle with random position, velocity, color, and lifetime.
fl::string fxName() const override
void draw(DrawContext context) override
Update and render all particles with overdraw technique.
void setLifetime(u16 lifetime_ms)
Set average particle lifetime in milliseconds.
Internal FastLED header for implementation files.
LIB8STATIC fl::u16 random16() FL_NOEXCEPT
Generate a 16-bit random number.
LIB8STATIC fl::u8 random8() FL_NOEXCEPT
Generate an 8-bit random number.
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
void blur1d(fl::span< CRGB > leds, fract8 blur_amount) FL_NOEXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT
Base definition for an LED controller.
CRGB & nscale8(u8 scaledown) FL_NOEXCEPT
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Representation of an 8-bit RGB pixel (Red, Green, Blue)
void draw(fl::span< CRGB > leds, u32 now, u16 numLeds)
Render particle with sub-pixel accuracy and power-modulated color.
CHSV baseColor
Base color (HSV) - saturation increases with age.
void update(u32 now, u16 numLeds, float speedMultiplier, bool cyclical)
Update position based on velocity × power.
void spawn(u16 numLeds)
Spawn with random position, velocity, color, and lifetime.
float getPower(u32 now) const
bool active
Active flag (false = available for reuse)
float pos
Position (floating point for sub-pixel rendering)
float baseVel
Base velocity (actual velocity = baseVel × power)
u32 lifetime
Lifespan in milliseconds.
u32 birthTime
Spawn timestamp (ms)