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

◆ draw()

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

Implements fl::IAnimartrix2Viz.

Definition at line 11 of file center_field.cpp.hpp.

11 {
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14
15 // Perlin noise is periodic with period 256 at integer coordinates.
16 // With scale_y = 0.07, the effective period for offset_y is 256/0.07 ≈ 3657.14.
17 // Reducing modulo this period keeps float32 precise at extreme uptimes.
18 static constexpr float perlin_period = 3657.14285714f; // 256.0f / 0.07f
19
20 e->timings.master_speed = 0.01;
21 e->timings.ratio[0] = 1;
22 e->timings.ratio[1] = 1.1;
23 e->timings.ratio[2] = 1.2;
24
25 e->timings.offset[1] = 100;
26 e->timings.offset[2] = 200;
27 e->timings.offset[3] = 300;
28
29 e->calculate_oscillators(e->timings);
30
31 for (int x = 0; x < e->num_x; x++) {
32 for (int y = 0; y < e->num_y; y++) {
33 e->animation.angle = e->polar_theta[x][y];
34 e->animation.scale_x = 0.07;
35 e->animation.scale_y = 0.07;
36 e->animation.scale_z = 0.1;
37 e->animation.dist = 5 * fl::sqrtf(e->distance[x][y]);
38 e->animation.offset_y = fl::fmodf(e->move.linear[0], perlin_period);
39 e->animation.offset_x = 0;
40 e->animation.z = 0;
41 float show1 = e->render_value(e->animation);
42
43 e->animation.angle = e->polar_theta[x][y];
44 e->animation.scale_x = 0.07;
45 e->animation.scale_y = 0.07;
46 e->animation.scale_z = 0.1;
47 e->animation.dist = 4 * fl::sqrtf(e->distance[x][y]);
48 e->animation.offset_y = fl::fmodf(e->move.linear[0], perlin_period);
49 e->animation.offset_x = 0;
50 e->animation.z = 0;
51 float show2 = e->render_value(e->animation);
52
53 e->pixel.red = show1;
54 e->pixel.green = show2;
55 e->pixel.blue = 0;
56
57 e->pixel = e->rgb_sanity_check(e->pixel);
58 e->setPixelColorInternal(x, y, e->pixel);
59 }
60 }
61}
float sqrtf(float value) FL_NOEXCEPT
Definition math.h:453
float fmodf(float x, float y) FL_NOEXCEPT
Definition math.h:336

References fl::fmodf(), fl::Context::mEngine, fl::sqrtf(), fl::x, and fl::y.

+ Here is the call graph for this function: