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