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

◆ draw()

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

Implements fl::IAnimartrix2Viz.

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

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

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

+ Here is the call graph for this function: