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