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

◆ draw()

void fl::Particles1d::Particle::draw ( fl::span< CRGB > leds,
u32 now,
u16 numLeds )

Render particle with sub-pixel accuracy and power-modulated color.

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

137 {
138 if (!active) return;
139 float power = getPower(now);
140 if (power <= 0.0f) return;
141
142 // Power effects: slow down, saturate, dim
143 u8 sat = baseColor.sat + (1.0f - power) * (255 - baseColor.sat);
144 u8 val = baseColor.val * power;
145 CRGB color = CHSV(baseColor.hue, sat, val);
146
147 // Sub-pixel rendering
148 int i = (int)pos;
149 float frac = pos - i;
150 if (i >= 0 && i < (int)numLeds)
151 leds[i] += color.nscale8(255 * (1.0f - frac));
152 if (i + 1 >= 0 && i + 1 < (int)numLeds && frac > 0)
153 leds[i + 1] += color.nscale8(255 * frac);
154}
fl::CRGB leds[NUM_LEDS]
fl::hsv8 CHSV
Definition chsv.h:11
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:15
CRGB & nscale8(u8 scaledown) FL_NOEXCEPT
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp.hpp:88
CHSV baseColor
Base color (HSV) - saturation increases with age.
Definition particles.h:105
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

References active, baseColor, getPower(), leds, fl::CRGB::nscale8(), and pos.

+ Here is the call graph for this function: