FastLED 3.9.15
Loading...
Searching...
No Matches
luminova.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/stdint.h"
4
5#include "crgb.h" // Needed for CRGB parameter types // IWYU pragma: keep
6#include "fl/stl/shared_ptr.h" // For FASTLED_SHARED_PTR macros // IWYU pragma: keep
7#include "fl/stl/shared_ptr.h" // For shared_ptr // IWYU pragma: keep
8#include "fl/fx/fx2d.h"
9
10namespace fl {
11
13
15 // Global fade amount applied each frame (higher = faster fade)
17 // Blur amount applied each frame for trail softness
19 // Per-dot gain applied to plotted pixels to prevent blowout on small grids
20 u8 point_gain = 128; // 50%
21 // Number of particles alive in the system (upper bound)
22 int max_particles = 256;
23};
24
25// 2D particle field with soft white trails inspired by the Luminova example.
26class Luminova : public Fx2d {
27 public:
29
30 explicit Luminova(const XYMap &xyMap, const Params &params = Params());
31
32 void draw(DrawContext context) override;
33
34 fl::string fxName() const override { return "Luminova"; }
35
36 void setFadeAmount(u8 fade_amount) { mParams.fade_amount = fade_amount; }
38 void setPointGain(u8 point_gain) { mParams.point_gain = point_gain; }
39
40 // Adjust maximum particle slots (reinitializes pool if size changes)
41 void setMaxParticles(int max_particles);
42
43 private:
44 struct Particle {
45 float x = 0.0f;
46 float y = 0.0f;
47 float a = 0.0f; // angle
48 int f = 0; // direction (+1 or -1)
49 int g = 0; // group id (derived from time)
50 float s = 0.0f; // stroke weight / intensity
51 bool alive = false;
52 };
53
54 void resetParticle(Particle &p, fl::u32 tick);
55 void plotDot(fl::span<CRGB> leds, int x, int y, u8 v) const;
56 void plotSoftDot(fl::span<CRGB> leds, float fx, float fy, float s) const;
57
59 fl::u32 mTick = 0;
61};
62
63} // namespace fl
fl::CRGB leds[NUM_LEDS]
Fx2d(const XYMap &xyMap)
Definition fx2d.h:19
u16 xyMap(u16 x, u16 y) const
Definition fx2d.h:20
void resetParticle(Particle &p, fl::u32 tick)
fl::u32 mTick
Definition luminova.h:59
void plotDot(fl::span< CRGB > leds, int x, int y, u8 v) const
void plotSoftDot(fl::span< CRGB > leds, float fx, float fy, float s) const
LuminovaParams Params
Definition luminova.h:28
Params mParams
Definition luminova.h:58
fl::string fxName() const override
Definition luminova.h:34
Luminova(const XYMap &xyMap, const Params &params=Params())
fl::vector< Particle > mParticles
Definition luminova.h:60
void draw(DrawContext context) override
void setMaxParticles(int max_particles)
void setBlurAmount(u8 blur_amount)
Definition luminova.h:37
void setFadeAmount(u8 fade_amount)
Definition luminova.h:36
void setPointGain(u8 point_gain)
Definition luminova.h:38
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount
Definition blur.h:186
Base definition for an LED controller.
Definition crgb.hpp:179
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:535