FastLED 3.9.15
Loading...
Searching...
No Matches
module_experiment7.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14
15 e->timings.master_speed = 0.005;
16
17 float w = 0.3;
18
19 e->timings.ratio[0] = 0.01;
20 e->timings.ratio[1] = 0.011;
21 e->timings.ratio[2] = 0.029;
22 e->timings.ratio[3] = 0.33 * w;
23 e->timings.ratio[4] = 0.36 * w;
24
25 e->calculate_oscillators(e->timings);
26
27 for (int x = 0; x < e->num_x; x++) {
28 for (int y = 0; y < e->num_y; y++) {
29
30 float s = 0.7;
31
32 e->animation.dist =
33 2 + e->distance[x][y] +
34 2 * fl::sinf(0.25 * e->distance[x][y] - e->move.radial[3]);
35 e->animation.angle = e->polar_theta[x][y];
36 e->animation.z = 5;
37 e->animation.scale_x = 0.1 * s;
38 e->animation.scale_y = 0.1 * s;
39 e->animation.offset_z = 10 * e->move.linear[0];
40 e->animation.offset_y = -20 * e->move.linear[0];
41 e->animation.offset_x = 10;
42 e->animation.low_limit = 0;
43 e->show1 = e->render_value(e->animation);
44
45 e->animation.dist =
46 2 + e->distance[x][y] +
47 2 * fl::sinf(0.24 * e->distance[x][y] - e->move.radial[4]);
48 e->animation.angle = e->polar_theta[x][y];
49 e->animation.z = 10;
50 e->animation.scale_x = 0.1 * s;
51 e->animation.scale_y = 0.1 * s;
52 e->animation.offset_z = 0.1 * e->move.linear[1];
53 e->animation.offset_y = -20 * e->move.linear[1];
54 e->animation.offset_x = 10;
55 e->animation.low_limit = 0;
56 e->show2 = e->render_value(e->animation);
57
58 e->pixel.red = (e->show1 + e->show2);
59 e->pixel.green = ((e->show1 + e->show2) * 0.6) - 50;
60 e->pixel.blue = 0;
61
62 e->pixel = e->rgb_sanity_check(e->pixel);
63
64 e->setPixelColorInternal(x, y, e->pixel);
65 }
66 }
67}
68
69
70// ============================================================================
71// Fixed-Point Implementation of Module_Experiment7
72// ============================================================================
73
75 auto *e = ctx.mEngine.get();
76 e->get_ready();
77 mState.ensureCache(e);
78 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
79 const fl::u8 *perm = PERLIN_NOISE;
80
81 e->timings.master_speed = 0.005;
82
83 float w = 0.3;
84
85 e->timings.ratio[0] = 0.01;
86 e->timings.ratio[1] = 0.011;
87 e->timings.ratio[2] = 0.029;
88 e->timings.ratio[3] = 0.33 * w;
89 e->timings.ratio[4] = 0.36 * w;
90
91 e->calculate_oscillators(e->timings);
92
93 for (int x = 0; x < e->num_x; x++) {
94 for (int y = 0; y < e->num_y; y++) {
95
96 float s = 0.7;
97
98 e->animation.dist =
99 2 + e->distance[x][y] +
100 2 * fl::sinf(0.25 * e->distance[x][y] - e->move.radial[3]);
101 e->animation.angle = e->polar_theta[x][y];
102 e->animation.z = 5;
103 e->animation.scale_x = 0.1 * s;
104 e->animation.scale_y = 0.1 * s;
105 e->animation.offset_z = 10 * e->move.linear[0];
106 e->animation.offset_y = -20 * e->move.linear[0];
107 e->animation.offset_x = 10;
108 e->animation.low_limit = 0;
109 e->show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
110
111 e->animation.dist =
112 2 + e->distance[x][y] +
113 2 * fl::sinf(0.24 * e->distance[x][y] - e->move.radial[4]);
114 e->animation.angle = e->polar_theta[x][y];
115 e->animation.z = 10;
116 e->animation.scale_x = 0.1 * s;
117 e->animation.scale_y = 0.1 * s;
118 e->animation.offset_z = 0.1 * e->move.linear[1];
119 e->animation.offset_y = -20 * e->move.linear[1];
120 e->animation.offset_x = 10;
121 e->animation.low_limit = 0;
122 e->show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
123
124 e->pixel.red = (e->show1 + e->show2);
125 e->pixel.green = ((e->show1 + e->show2) * 0.6) - 50;
126 e->pixel.blue = 0;
127
128 e->pixel = e->rgb_sanity_check(e->pixel);
129
130 e->setPixelColorInternal(x, y, e->pixel);
131 }
132 }
133}
134
135} // namespace fl
136
void draw(Context &ctx) override
void draw(Context &ctx) override
unsigned char u8
Definition s16x16x4.h:132
T * assume_aligned(T *ptr) FL_NOEXCEPT
Definition s16x16x4.h:126
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
FASTLED_FORCE_INLINE fl::i32 render_value_fp_from_float(const render_parameters &anim, const fl::i32 *fade_lut, const fl::u8 *perm)
Base definition for an LED controller.
Definition crgb.hpp:179
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FL_FAST_MATH_BEGIN
#define FL_FAST_MATH_END
#define FL_OPTIMIZATION_LEVEL_O3_END
fl::unique_ptr< Engine > mEngine
Definition context.h:38