FastLED 3.9.15
Loading...
Searching...
No Matches
module_experiment8.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.01;
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.013;
22 e->timings.ratio[3] = 0.33 * w;
23 e->timings.ratio[4] = 0.36 * w;
24 e->timings.ratio[5] = 0.38 * w;
25 e->timings.ratio[6] = 0.0003;
26
27 e->timings.offset[0] = 0;
28 e->timings.offset[1] = 100;
29 e->timings.offset[2] = 200;
30 e->timings.offset[3] = 300;
31 e->timings.offset[4] = 400;
32 e->timings.offset[5] = 500;
33 e->timings.offset[6] = 600;
34
35 e->calculate_oscillators(e->timings);
36
37 for (int x = 0; x < e->num_x; x++) {
38 for (int y = 0; y < e->num_y; y++) {
39
40 float s = 0.4;
41 float r = 1.5;
42
43 e->animation.dist =
44 3 + e->distance[x][y] +
45 3 * fl::sinf(0.25 * e->distance[x][y] - e->move.radial[3]);
46 e->animation.angle = e->polar_theta[x][y] + e->move.noise_angle[0] +
47 e->move.noise_angle[6];
48 e->animation.z = 5;
49 e->animation.scale_x = 0.1 * s;
50 e->animation.scale_y = 0.1 * s;
51 e->animation.offset_z = 10 * e->move.linear[0];
52 e->animation.offset_y = -5 * r * e->move.linear[0];
53 e->animation.offset_x = 10;
54 e->animation.low_limit = 0;
55 e->show1 = e->render_value(e->animation);
56
57 e->animation.dist =
58 4 + e->distance[x][y] +
59 4 * fl::sinf(0.24 * e->distance[x][y] - e->move.radial[4]);
60 e->animation.angle = e->polar_theta[x][y] + e->move.noise_angle[1] +
61 e->move.noise_angle[6];
62 e->animation.z = 5;
63 e->animation.scale_x = 0.1 * s;
64 e->animation.scale_y = 0.1 * s;
65 e->animation.offset_z = 0.1 * e->move.linear[1];
66 e->animation.offset_y = -5 * r * e->move.linear[1];
67 e->animation.offset_x = 100;
68 e->animation.low_limit = 0;
69 e->show2 = e->render_value(e->animation);
70
71 e->animation.dist =
72 5 + e->distance[x][y] +
73 5 * fl::sinf(0.23 * e->distance[x][y] - e->move.radial[5]);
74 e->animation.angle = e->polar_theta[x][y] + e->move.noise_angle[2] +
75 e->move.noise_angle[6];
76 e->animation.z = 5;
77 e->animation.scale_x = 0.1 * s;
78 e->animation.scale_y = 0.1 * s;
79 e->animation.offset_z = 0.1 * e->move.linear[2];
80 e->animation.offset_y = -5 * r * e->move.linear[2];
81 e->animation.offset_x = 1000;
82 e->animation.low_limit = 0;
83 e->show3 = e->render_value(e->animation);
84
85 e->show4 = e->colordodge(e->show1, e->show2);
86
87 float rad = fl::sinf(PI / 2 +
88 e->distance[x][y] / 14);
89
90 e->pixel.red = rad * ((e->show1 + e->show2) + e->show3);
91 e->pixel.green = (((e->show2 + e->show3) * 0.8) - 90) * rad;
92 e->pixel.blue = e->show4 * 0.2;
93
94 e->pixel = e->rgb_sanity_check(e->pixel);
95
96 e->setPixelColorInternal(x, y, e->pixel);
97 }
98 }
99}
100
101
102// ============================================================================
103// Fixed-Point Implementation of Module_Experiment8
104// ============================================================================
105
107 auto *e = ctx.mEngine.get();
108 e->get_ready();
109 mState.ensureCache(e);
110 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
111 const fl::u8 *perm = PERLIN_NOISE;
112
113 e->timings.master_speed = 0.01;
114
115 float w = 0.3;
116
117 e->timings.ratio[0] = 0.01;
118 e->timings.ratio[1] = 0.011;
119 e->timings.ratio[2] = 0.013;
120 e->timings.ratio[3] = 0.33 * w;
121 e->timings.ratio[4] = 0.36 * w;
122 e->timings.ratio[5] = 0.38 * w;
123 e->timings.ratio[6] = 0.0003;
124
125 e->timings.offset[0] = 0;
126 e->timings.offset[1] = 100;
127 e->timings.offset[2] = 200;
128 e->timings.offset[3] = 300;
129 e->timings.offset[4] = 400;
130 e->timings.offset[5] = 500;
131 e->timings.offset[6] = 600;
132
133 e->calculate_oscillators(e->timings);
134
135 for (int x = 0; x < e->num_x; x++) {
136 for (int y = 0; y < e->num_y; y++) {
137
138 float s = 0.4;
139 float r = 1.5;
140
141 e->animation.dist =
142 3 + e->distance[x][y] +
143 3 * fl::sinf(0.25 * e->distance[x][y] - e->move.radial[3]);
144 e->animation.angle = e->polar_theta[x][y] + e->move.noise_angle[0] +
145 e->move.noise_angle[6];
146 e->animation.z = 5;
147 e->animation.scale_x = 0.1 * s;
148 e->animation.scale_y = 0.1 * s;
149 e->animation.offset_z = 10 * e->move.linear[0];
150 e->animation.offset_y = -5 * r * e->move.linear[0];
151 e->animation.offset_x = 10;
152 e->animation.low_limit = 0;
153 e->show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
154
155 e->animation.dist =
156 4 + e->distance[x][y] +
157 4 * fl::sinf(0.24 * e->distance[x][y] - e->move.radial[4]);
158 e->animation.angle = e->polar_theta[x][y] + e->move.noise_angle[1] +
159 e->move.noise_angle[6];
160 e->animation.z = 5;
161 e->animation.scale_x = 0.1 * s;
162 e->animation.scale_y = 0.1 * s;
163 e->animation.offset_z = 0.1 * e->move.linear[1];
164 e->animation.offset_y = -5 * r * e->move.linear[1];
165 e->animation.offset_x = 100;
166 e->animation.low_limit = 0;
167 e->show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
168
169 e->animation.dist =
170 5 + e->distance[x][y] +
171 5 * fl::sinf(0.23 * e->distance[x][y] - e->move.radial[5]);
172 e->animation.angle = e->polar_theta[x][y] + e->move.noise_angle[2] +
173 e->move.noise_angle[6];
174 e->animation.z = 5;
175 e->animation.scale_x = 0.1 * s;
176 e->animation.scale_y = 0.1 * s;
177 e->animation.offset_z = 0.1 * e->move.linear[2];
178 e->animation.offset_y = -5 * r * e->move.linear[2];
179 e->animation.offset_x = 1000;
180 e->animation.low_limit = 0;
181 e->show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
182
183 e->show4 = e->colordodge(e->show1, e->show2);
184
185 float rad = fl::sinf(PI / 2 +
186 e->distance[x][y] / 14);
187
188 e->pixel.red = rad * ((e->show1 + e->show2) + e->show3);
189 e->pixel.green = (((e->show2 + e->show3) * 0.8) - 90) * rad;
190 e->pixel.blue = e->show4 * 0.2;
191
192 e->pixel = e->rgb_sanity_check(e->pixel);
193
194 e->setPixelColorInternal(x, y, e->pixel);
195 }
196 }
197}
198
199} // namespace fl
200
#define PI
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