150 {
152 e->get_ready();
153
154
155 e->timings.master_speed = 0.01;
156 e->timings.ratio[0] = 0.1;
157 e->timings.ratio[1] = 0.13;
158 e->timings.ratio[2] = 0.16;
159 e->timings.offset[1] = 10;
160 e->timings.offset[2] = 20;
161 e->timings.offset[3] = 30;
162 e->calculate_oscillators(e->timings);
163
164 const int num_x = e->num_x;
165 const int num_y = e->num_y;
166 const int total_pixels = num_x * num_y;
167
168
170 const FP radius_fp(e->radial_filter_radius);
171 const FP center_x_scaled =
FP(e->animation.center_x * 0.1f);
172 const FP center_y_scaled =
FP(e->animation.center_y * 0.1f);
173
174 const FP radial0(e->move.radial[0]);
175 const FP radial1(e->move.radial[1]);
176 const FP radial2(e->move.radial[2]);
177
178
179
180
181
182
183
184
185
186
187
188
189 constexpr float perlin_period = 2560.0f;
190 constexpr float scale_f = 0.1f;
191 const FP linear0_scaled =
FP(
fmodf(e->move.linear[0], perlin_period) * scale_f);
192 const FP linear1_scaled =
FP(
fmodf(e->move.linear[1], perlin_period) * scale_f);
193 const FP linear2_scaled =
FP(
fmodf(e->move.linear[2], perlin_period) * scale_f);
194
195 constexpr FP three_fp(3.0f);
196 constexpr FP one(1.0f);
197
198
199 if (
state.count != total_pixels) {
200 const int padded = (total_pixels + 3) & ~3;
201 state.base_angle.resize(padded, 0);
202 state.dist_scaled.resize(padded, 0);
203 state.rf3.resize(padded, 0);
204 state.rf_half.resize(padded, 0);
205 state.rf_quarter.resize(padded, 0);
206 state.pixel_idx.resize(padded, 0);
207
208 const FP inv_radius = one / radius_fp;
209 const FP one_third = one / three_fp;
210 int idx = 0;
211 for (
int x = 0;
x < num_x;
x++) {
212 for (
int y = 0;
y < num_y;
y++) {
213 const FP theta(e->polar_theta[
x][
y]);
214 const FP dist(e->distance[
x][
y]);
215 const FP rf = (radius_fp - dist) * inv_radius;
216 state.base_angle[idx] = (three_fp * theta - dist * one_third).raw();
217 state.dist_scaled[idx] = (dist *
scale).raw();
218 state.rf3[idx] = (three_fp * rf).raw();
219 state.rf_half[idx] = (rf >> 1).raw();
220 state.rf_quarter[idx] = (rf >> 2).raw();
221 state.pixel_idx[idx] = e->mCtx->xyMapFn(
x,
y, e->mCtx->xyMapUserData);
222 idx++;
223 }
224 }
225 state.count = total_pixels;
226 }
227
228
229 if (!
state.fade_lut_initialized) {
231 state.fade_lut_initialized =
true;
232 }
233
234 const i32 cx_raw = center_x_scaled.
raw();
235 const i32 cy_raw = center_y_scaled.
raw();
236 const i32 lin0_raw = linear0_scaled.
raw();
237 const i32 lin1_raw = linear1_scaled.
raw();
238 const i32 lin2_raw = linear2_scaled.
raw();
239 const i32 rad0_raw = radial0.raw();
240 const i32 rad1_raw = radial1.raw();
241 const i32 rad2_raw = radial2.raw();
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
265 total_pixels,
271 state.pixel_idx.data(),
273 PERLIN_NOISE,
274 cx_raw,
275 cy_raw,
276 lin0_raw,
277 lin1_raw,
278 lin2_raw,
279 rad0_raw,
280 rad1_raw,
281 rad2_raw,
282 e->mCtx->leds
283 };
284}
fl::UISlider scale("Scale", 4,.1, 4,.1)
constexpr i32 raw() const FL_NOEXCEPT
T * assume_aligned(T *ptr) FL_NOEXCEPT
float fmodf(float x, float y) FL_NOEXCEPT
fl::unique_ptr< Engine > mEngine
static void init_fade_lut(fl::i32 *table)