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