FastLED 3.10.8
Loading...
Searching...
No Matches

◆ draw()

void fl::Chasing_Spirals_Float::draw ( Context & ctx)
overridevirtual

Implements fl::IAnimartrix2Viz.

Definition at line 293 of file chasing_spirals.cpp.hpp.

293 {
294 auto *e = ctx.mEngine.get();
295 e->get_ready();
296
297 // Perlin noise is periodic with period 256 at integer coordinates.
298 // scale_x = 0.1, so the effective period for offset_x is 256/0.1 = 2560.
299 // Reducing move.linear[i] modulo this period before use keeps float32
300 // coordinate arithmetic precise even at extreme uptime values.
301 // Without this, float32 loses per-pixel precision when adding a small
302 // per-pixel term (~0.1) to a large offset (e.g. 200,000), since float32
303 // ULP at that magnitude (~0.024) is coarser than the per-pixel step.
304 // This matches the reduction already applied in setupChasingSpiralFrame
305 // for the Q31 path, keeping both paths in agreement at all time values.
306 static constexpr float perlin_period = 2560.0f; // 256.0f / scale_x(0.1f)
307
308 e->timings.master_speed = 0.01;
309 e->timings.ratio[0] = 0.1;
310 e->timings.ratio[1] = 0.13;
311 e->timings.ratio[2] = 0.16;
312 e->timings.offset[1] = 10;
313 e->timings.offset[2] = 20;
314 e->timings.offset[3] = 30;
315 e->calculate_oscillators(e->timings);
316
317 for (int x = 0; x < e->num_x; x++) {
318 for (int y = 0; y < e->num_y; y++) {
319 e->animation.angle =
320 3 * e->polar_theta[x][y] + e->move.radial[0] -
321 e->distance[x][y] / 3;
322 e->animation.dist = e->distance[x][y];
323 e->animation.scale_z = 0.1;
324 e->animation.scale_y = 0.1;
325 e->animation.scale_x = 0.1;
326 e->animation.offset_x = fl::fmodf(e->move.linear[0], perlin_period);
327 e->animation.offset_y = 0;
328 e->animation.offset_z = 0;
329 e->animation.z = 0;
330 float show1 = e->render_value(e->animation);
331
332 e->animation.angle =
333 3 * e->polar_theta[x][y] + e->move.radial[1] -
334 e->distance[x][y] / 3;
335 e->animation.dist = e->distance[x][y];
336 e->animation.offset_x = fl::fmodf(e->move.linear[1], perlin_period);
337 float show2 = e->render_value(e->animation);
338
339 e->animation.angle =
340 3 * e->polar_theta[x][y] + e->move.radial[2] -
341 e->distance[x][y] / 3;
342 e->animation.dist = e->distance[x][y];
343 e->animation.offset_x = fl::fmodf(e->move.linear[2], perlin_period);
344 float show3 = e->render_value(e->animation);
345
346 float radius = e->radial_filter_radius;
347 float radial_filter = (radius - e->distance[x][y]) / radius;
348
349 e->pixel.red = 3 * show1 * radial_filter;
350 e->pixel.green = show2 * radial_filter / 2;
351 e->pixel.blue = show3 * radial_filter / 4;
352
353 e->pixel = e->rgb_sanity_check(e->pixel);
354 e->setPixelColorInternal(x, y, e->pixel);
355 }
356 }
357}
float fmodf(float x, float y) FL_NO_EXCEPT
Definition math.h:344

References fl::FL_NO_EXCEPT, fl::fmodf(), fl::x, and fl::y.

+ Here is the call graph for this function: