FastLED 3.9.15
Loading...
Searching...
No Matches
parametric_water.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.003;
16 e->timings.ratio[0] = 0.025;
17 e->timings.ratio[1] = 0.027;
18 e->timings.ratio[2] = 0.029;
19 e->timings.ratio[3] = 0.033;
20 e->timings.ratio[4] = 0.037;
21 e->timings.ratio[5] = 0.15;
22 e->timings.ratio[6] = 0.41;
23
24 e->calculate_oscillators(e->timings);
25
26 for (int x = 0; x < e->num_x; x++) {
27 for (int y = 0; y < e->num_y; y++) {
28
29 float s = 4;
30 float f = 10 + 2 * e->move.directional[0];
31
32 e->animation.dist = (f + e->move.directional[0]) *
33 fl::sinf(-e->move.radial[5] + e->move.radial[0] +
34 (e->distance[x][y] / (s)));
35 e->animation.angle = 1 * e->polar_theta[x][y];
36 e->animation.z = 5;
37 e->animation.scale_x = 0.1;
38 e->animation.scale_y = 0.1;
39 e->animation.offset_z = -10;
40 e->animation.offset_y = 20 * e->move.linear[0];
41 e->animation.offset_x = 10;
42 e->animation.low_limit = 0;
43 e->show2 = e->render_value(e->animation);
44
45 e->animation.dist = (f + e->move.directional[1]) *
46 fl::sinf(-e->move.radial[5] + e->move.radial[1] +
47 (e->distance[x][y] / (s)));
48 e->animation.angle = 1 * e->polar_theta[x][y];
49 e->animation.z = 500;
50 e->animation.scale_x = 0.1;
51 e->animation.scale_y = 0.1;
52 e->animation.offset_z = -10;
53 e->animation.offset_y = 20 * e->move.linear[1];
54 e->animation.offset_x = 10;
55 e->animation.low_limit = 0;
56 e->show3 = e->render_value(e->animation);
57
58 e->animation.dist = (f + e->move.directional[2]) *
59 fl::sinf(-e->move.radial[5] + e->move.radial[2] +
60 (e->distance[x][y] / (s)));
61 e->animation.angle = 1 * e->polar_theta[x][y];
62 e->animation.z = 5000;
63 e->animation.scale_x = 0.1;
64 e->animation.scale_y = 0.1;
65 e->animation.offset_z = -10;
66 e->animation.offset_y = 20 * e->move.linear[2];
67 e->animation.offset_x = 10;
68 e->animation.low_limit = 0;
69 e->show4 = e->render_value(e->animation);
70
71 e->animation.dist = (f + e->move.directional[3]) *
72 fl::sinf(-e->move.radial[5] + e->move.radial[3] +
73 (e->distance[x][y] / (s)));
74 e->animation.angle = 1 * e->polar_theta[x][y];
75 e->animation.z = 2000;
76 e->animation.scale_x = 0.1;
77 e->animation.scale_y = 0.1;
78 e->animation.offset_z = -10;
79 e->animation.offset_y = 20 * e->move.linear[3];
80 e->animation.offset_x = 10;
81 e->animation.low_limit = 0;
82 e->show5 = e->render_value(e->animation);
83
84 e->show6 = e->screen(e->show4, e->show5);
85 e->show7 = e->screen(e->show2, e->show3);
86
87 float radius = 40;
88 float radial = (radius - e->distance[x][y]) / radius;
89
90 e->pixel.red = e->pixel.blue - 40;
91 e->pixel.green = 0;
92 e->pixel.blue = (0.3 * e->show6 + 0.7 * e->show7) * radial;
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 Parametric_Water
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.003;
114 e->timings.ratio[0] = 0.025;
115 e->timings.ratio[1] = 0.027;
116 e->timings.ratio[2] = 0.029;
117 e->timings.ratio[3] = 0.033;
118 e->timings.ratio[4] = 0.037;
119 e->timings.ratio[5] = 0.15;
120 e->timings.ratio[6] = 0.41;
121
122 e->calculate_oscillators(e->timings);
123
124 for (int x = 0; x < e->num_x; x++) {
125 for (int y = 0; y < e->num_y; y++) {
126
127 float s = 4;
128 float f = 10 + 2 * e->move.directional[0];
129
130 e->animation.dist = (f + e->move.directional[0]) *
131 fl::sinf(-e->move.radial[5] + e->move.radial[0] +
132 (e->distance[x][y] / (s)));
133 e->animation.angle = 1 * e->polar_theta[x][y];
134 e->animation.z = 5;
135 e->animation.scale_x = 0.1;
136 e->animation.scale_y = 0.1;
137 e->animation.offset_z = -10;
138 e->animation.offset_y = 20 * e->move.linear[0];
139 e->animation.offset_x = 10;
140 e->animation.low_limit = 0;
141 e->show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
142
143 e->animation.dist = (f + e->move.directional[1]) *
144 fl::sinf(-e->move.radial[5] + e->move.radial[1] +
145 (e->distance[x][y] / (s)));
146 e->animation.angle = 1 * e->polar_theta[x][y];
147 e->animation.z = 500;
148 e->animation.scale_x = 0.1;
149 e->animation.scale_y = 0.1;
150 e->animation.offset_z = -10;
151 e->animation.offset_y = 20 * e->move.linear[1];
152 e->animation.offset_x = 10;
153 e->animation.low_limit = 0;
154 e->show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
155
156 e->animation.dist = (f + e->move.directional[2]) *
157 fl::sinf(-e->move.radial[5] + e->move.radial[2] +
158 (e->distance[x][y] / (s)));
159 e->animation.angle = 1 * e->polar_theta[x][y];
160 e->animation.z = 5000;
161 e->animation.scale_x = 0.1;
162 e->animation.scale_y = 0.1;
163 e->animation.offset_z = -10;
164 e->animation.offset_y = 20 * e->move.linear[2];
165 e->animation.offset_x = 10;
166 e->animation.low_limit = 0;
167 e->show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
168
169 e->animation.dist = (f + e->move.directional[3]) *
170 fl::sinf(-e->move.radial[5] + e->move.radial[3] +
171 (e->distance[x][y] / (s)));
172 e->animation.angle = 1 * e->polar_theta[x][y];
173 e->animation.z = 2000;
174 e->animation.scale_x = 0.1;
175 e->animation.scale_y = 0.1;
176 e->animation.offset_z = -10;
177 e->animation.offset_y = 20 * e->move.linear[3];
178 e->animation.offset_x = 10;
179 e->animation.low_limit = 0;
180 e->show5 = render_value_fp_from_float(e->animation, fade_lut, perm);
181
182 e->show6 = e->screen(e->show4, e->show5);
183 e->show7 = e->screen(e->show2, e->show3);
184
185 float radius = 40;
186 float radial = (radius - e->distance[x][y]) / radius;
187
188 e->pixel.red = e->pixel.blue - 40;
189 e->pixel.green = 0;
190 e->pixel.blue = (0.3 * e->show6 + 0.7 * e->show7) * radial;
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
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