12 if (v <= 0.0f)
return 0;
13 if (v >= 255.0f)
return 255;
73 CRGBPalette16 defaultPalette(
CRGB(0, 0, 40),
CRGB(0, 40, 120),
83 return "PerlinParticlePunch";
114 float diff = 1.0f - drag;
156 float jitter = float(
random8(80, 120)) / 100.0f;
167 if (intensity < 0.0f)
169 if (intensity > 1.0f)
187 for (u16 i = 0; i < n; ++i) {
199 for (u16 i = 0; i < n; ++i) {
211 for (u16 i = 0; i < n; ++i) {
228 return (
x - in_min) / (in_max - in_min) * (out_max - out_min) + out_min;
243 constexpr s16x16 one(1.0f);
256 constexpr s16x16 two_pi(6.2831853f);
258 s16x16 theta = -time_factor;
259 constexpr s16x16 threshold(32.0f);
260 constexpr s16x16 zero(0.0f);
261 constexpr s16x16 max_val(255.0f);
262 for (u16 i = 0; i <
mNumLeds; ++i) {
264 if (val < threshold) {
267 val =
mapf(val, threshold, max_val, zero, max_val);
272 theta = theta +
step;
290 int center = int(p.position);
291 float frac = p.position - float(center);
292 u8 bri = clamp_u8(p.brightness);
297 int idx = center -
offset;
302 float falloff = 1.0f - (float(
offset) / float(p.headWidth)) * 0.8f;
303 CRGB pixel = baseColor;
304 pixel.
nscale8(clamp_u8(falloff * 255.0f));
307 if (
offset == 0 && frac > 0.01f) {
308 int nextIdx = center + 1;
310 CRGB subPixel = pixel;
311 subPixel.
nscale8(clamp_u8(frac * 255.0f));
314 pixel.
nscale8(clamp_u8((1.0f - frac) * 255.0f));
322 int center = int(m.position);
325 static const float kGaussian[] = {0.15f, 0.60f, 1.0f, 0.60f, 0.15f};
327 int idx = center +
offset;
330 float weight = kGaussian[
offset + 2];
331 u8 bri = clamp_u8(255.0f * m.intensity * weight);
333 bri = scale8(bri,
random8(153, 255));
340 float tailLen = m.tailLength();
341 int tailPixels = int(tailLen);
342 for (
int i = 1; i <= tailPixels; ++i) {
343 int idx = center - i;
350 float t = float(i) / float(tailPixels);
351 fract8 blendAmt = clamp_u8(
t * 255.0f);
354 float bri = (1.0f -
t *
t) * m.intensity;
355 tailColor.
nscale8(clamp_u8(bri * 255.0f));
361 int idx = int(d.position);
362 float frac = d.position - float(idx);
363 u8 bri = clamp_u8(d.brightness);
364 CRGB pixel = d.color;
369 main.nscale8(clamp_u8((1.0f - frac) * 255.0f));
372 int nextIdx = idx + 1;
373 if (nextIdx >= 0 && nextIdx < mNumLeds && frac > 0.01f) {
375 sub.
nscale8(clamp_u8(frac * 255.0f));
385 float tailLen = m.tailLength();
386 u8 maxOffset = clamp_u8(tailLen);
389 float spawnOffset = float(
random8(2, maxOffset));
390 float spawnPos = m.position - spawnOffset;
395 float t = spawnOffset / tailLen;
398 fract8 blendAmt = clamp_u8(
t * 255.0f);
405 d->
color = debrisColor;
418 u32 now = context.now;
429 u8 decayRate = 255 - trailIntensity;
486 for (u16 i = 0; i <
mNumLeds; ++i) {
UINumberField palette("Palette", 0, 0, 2)
Fx1d(u16 numLeds) FL_NO_EXCEPT
static void writeMax(CRGB &dst, const CRGB &src) FL_NO_EXCEPT
void setDebrisVelocityDecay(float decay) FL_NO_EXCEPT
Per-frame velocity decay for debris particles. Default 0.95.
MeteorParticle * tryAllocateMeteor() FL_NO_EXCEPT
void setDrag(float drag) FL_NO_EXCEPT
Set per-frame drag for ambient particles (0.0 = instant stop, 1.0 = no drag).
DebrisParticle * tryAllocateDebris() FL_NO_EXCEPT
fl::vector< DebrisParticle > mDebrisParticles
fl::vector< MeteorParticle > mMeteorParticles
void renderDebris(const DebrisParticle &d) FL_NO_EXCEPT
void renderAmbient(const AmbientParticle &p) FL_NO_EXCEPT
void renderMeteor(const MeteorParticle &m) FL_NO_EXCEPT
void setMeteorGradient(CRGB headColor, CRGB midColor, CRGB tailColor) FL_NO_EXCEPT
Set the meteor color gradient: head → mid → tail.
void setAmbientTrailIntensity(u8 intensity) FL_NO_EXCEPT
Ambient trail intensity: 0 = no trail, 255 = long persistent trail.
PerlinParticlePunch(u16 num_leds) FL_NO_EXCEPT
float mDebrisBrightnessDecay
void setNoisePalette(const CRGBPalette16 &palette) FL_NO_EXCEPT
Set palette for Perlin noise background.
void setSpeed(float speed) FL_NO_EXCEPT
Set velocity multiplier. Default 1.0.
void draw(DrawContext context) FL_NO_EXCEPT override
void spawnMeteor(float intensity=1.0f) FL_NO_EXCEPT
Spawn a BEAT meteor at position 0, traveling toward end of strip.
AmbientParticle * tryAllocateAmbient() FL_NO_EXCEPT
void setTimeMultiplier(float mult) FL_NO_EXCEPT
Set time multiplier for noise evolution (1.0 = normal, >1 = warp).
void spawnDebrisFromMeteor(MeteorParticle &m, u32 now) FL_NO_EXCEPT
fl::string fxName() const FL_NO_EXCEPT override
CRGBPalette16 mAmbientPalette
void spawnAmbient(float intensity=0.5f) FL_NO_EXCEPT
Spawn an ambient particle at a random position.
void setMeteorTrailIntensity(u8 intensity) FL_NO_EXCEPT
Meteor trail intensity: controls how long meteor/debris trails linger.
float mDebrisVelocityDecay
CRGBPalette16 mNoisePalette
fl::vector< CRGB > mTrailBuffer
float mAmbientBrightnessDecay
void setDebrisBrightnessDecay(float decay) FL_NO_EXCEPT
Per-frame brightness decay for debris particles. Default 0.90.
s16x16 circleNoiseGen(u32 now, s16x16 theta) const FL_NO_EXCEPT
void setAmbientBrightnessDecay(float decay) FL_NO_EXCEPT
Per-frame brightness decay for ambient particles.
void setAmbientPalette(const CRGBPalette16 &palette) FL_NO_EXCEPT
Set palette for ambient particles.
void setMinVelocity(float minVel) FL_NO_EXCEPT
Minimum velocity before a particle dies.
u8 mAmbientTrailIntensity
void noiseCircleDraw(u32 now, fl::span< CRGB > dst) FL_NO_EXCEPT
static s16x16 mapf(s16x16 x, s16x16 in_min, s16x16 in_max, s16x16 out_min, s16x16 out_max) FL_NO_EXCEPT
fl::vector< AmbientParticle > mAmbientParticles
~PerlinParticlePunch() FL_NO_EXCEPT
static constexpr i32 SCALE
static constexpr int FRAC_BITS
constexpr i32 raw() const FL_NO_EXCEPT
static constexpr FASTLED_FORCE_INLINE s16x16 from_raw(i32 raw) FL_NO_EXCEPT
static FASTLED_FORCE_INLINE void sincos(s16x16 angle, s16x16 &out_sin, s16x16 &out_cos) FL_NO_EXCEPT
constexpr i32 to_int() const FL_NO_EXCEPT
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
fl::u16 inoise16(fl::u32 x, fl::u32 y, fl::u32 z, fl::u32 t) FL_NO_EXCEPT
LIB8STATIC fl::u8 random8() FL_NO_EXCEPT
Generate an 8-bit random number.
u8 clamp_u8(float v) FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
void fadeToBlackBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy) FL_NO_EXCEPT
u8 fract8
Fixed-Point Fractional Types.
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2) FL_NO_EXCEPT
constexpr enable_if< is_fixed_point< T >::value, T >::type step(T edge, T x) FL_NO_EXCEPT
CRGB ColorFromPalette(const CRGBPalette16 &pal, fl::u8 index, fl::u8 brightness, TBlendType blendType) FL_NO_EXCEPT
Base definition for an LED controller.
Audio-reactive perlin noise background with ambient particles and beat meteor overlay.
CRGB & nscale8(u8 scaledown) FL_NO_EXCEPT
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>
Representation of an 8-bit RGB pixel (Red, Green, Blue)
bool shouldSpawnDebris() const FL_NO_EXCEPT
float tailLength() const FL_NO_EXCEPT
float mapf(float x, float in_min, float in_max, float out_min, float out_max)