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