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

◆ loop()

void loop ( )

Definition at line 129 of file Luminova.h.

129 {
130 // Processing does: background(0, t?9:!createCanvas(...)+W); filter(BLUR)
131 // We emulate a very light global fade + blur to leave trails.
132 // First a tiny global fade, then a mild Gaussian-ish blur.
133 fadeToBlackBy(leds, NUM_LEDS, 18); // stronger fade to prevent blowout
134 blur2d(leds, WIDTH, HEIGHT, 24, xymap); // slightly gentler blur for 32x32
135
136 // Spawn/overwrite one particle per frame, round-robin
137 resetParticle(ps[t % MAXP], t);
138
139 // Update & draw all particles
140 for (int i = 0; i < MAXP; ++i) {
141 if (!ps[i].alive)
142 continue;
143 P &p = ps[i];
144
145 // strokeWeight(p.s *= .997)
146 p.s *= 0.997f;
147 if (p.s < 0.5f) {
148 p.alive = false;
149 continue;
150 } // cheap cull
151
152 // a += (noise(t/99, p.g) - .5) / 9
153 // Use 2D noise: (t/99, g). inoise8 returns 0..255; center at ~128.
154 float tOver99 = (float)t / 99.0f;
155 uint8_t n2 = inoise8((uint16_t)(tOver99 * 4096), (uint16_t)(p.g * 37));
156 float n2c = ((int)n2 - 128) / 255.0f; // ~ -0.5 .. +0.5
157 p.a += (n2c) / 9.0f;
158
159 // x += cos((a)*f), y += sin(a*f) (original had (a+=...)*f inside cos)
160 float aa = p.a * (float)p.f;
161 p.x += fl::cosf(aa);
162 p.y += fl::sinf(aa);
163
164 // draw white point with softness according to s
165 plotSoftDot(p.x, p.y, p.s);
166 }
167
168 FastLED.show();
169 t++;
170 // Cap frame rate a bit like Processing's draw loop
171 FastLED.delay(16); // ~60 FPS
172}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
XYMap xymap
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
#define WIDTH
#define HEIGHT
void fadeToBlackBy(CRGB *leds, fl::u16 num_leds, fl::u8 fadeBy)
void blur2d(fl::span< CRGB > leds, u8 width, u8 height, fract8 blur_amount, const XYMap &xymap) FL_NOEXCEPT
Definition blur.h:153
void plotSoftDot(float fx, float fy, float s)
Definition Luminova.h:85
void resetParticle(P &p, uint32_t tt)
Definition Luminova.h:59
static const int MAXP
Definition Luminova.h:56
static uint32_t t
Definition Luminova.h:55
P ps[MAXP]
Definition Luminova.h:57
int g
Definition Luminova.h:50
int f
Definition Luminova.h:49
bool alive
Definition Luminova.h:52
float y
Definition Luminova.h:47
float s
Definition Luminova.h:51
float a
Definition Luminova.h:48
float x
Definition Luminova.h:47
Definition Luminova.h:46
fl::u8 inoise8(fl::u16 x, fl::u16 y, fl::u16 z)
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
float cosf(float value) FL_NOEXCEPT
Definition math.h:358
unsigned char uint8_t
Definition s16x16x4.h:209

References P::a, P::alive, blur2d(), fl::cosf(), P::f, fadeToBlackBy(), FastLED, P::g, HEIGHT, inoise8(), leds, MAXP, NUM_LEDS, plotSoftDot(), ps, resetParticle(), P::s, fl::sinf(), t, WIDTH, P::x, xymap, and P::y.

+ Here is the call graph for this function: