MCPcopy Create free account
hub / github.com/FastLED/FastLED / flowPrepare

Method flowPrepare

src/fl/fx/2d/flowfield.cpp.hpp:277–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

275}
276
277void FlowFieldFloat::flowPrepare(float t) {
278 int w = (int)getWidth();
279 int h = (int)getHeight();
280 const float kBaseFreq = 0.23f;
281
282 for (int i = 0; i < w; i++) {
283 float v = mNoiseGenX.noise(
284 i * kBaseFreq * mParams.noise_freq_x + t * mParams.flow_speed_x,
285 0.0f);
286 mXProf[i] = clampf(v * mParams.flow_amp_x, -1.0f, 1.0f);
287 }
288
289 if (mParams.reverse_x_profile) {
290 for (int i = 0; i < w / 2; i++) {
291 float tmp = mXProf[i];
292 mXProf[i] = mXProf[w - 1 - i];
293 mXProf[w - 1 - i] = tmp;
294 }
295 }
296
297 for (int i = 0; i < h; i++) {
298 float v = mNoiseGenY.noise(
299 i * kBaseFreq * mParams.noise_freq_y + t * mParams.flow_speed_y,
300 0.0f);
301 mYProf[i] = clampf(v * mParams.flow_amp_y, -1.0f, 1.0f);
302 }
303
304 // Apply noise bias (attack/decay bumps from noisePunch triggers).
305 for (int i = 0; i < w; i++) {
306 mXProf[i] = clampf(mXProf[i] + mNoiseBias.getX(i), -1.0f, 1.0f);
307 }
308 for (int i = 0; i < h; i++) {
309 mYProf[i] = clampf(mYProf[i] + mNoiseBias.getY(i), -1.0f, 1.0f);
310 }
311}
312
313void FlowFieldFloat::flowAdvect(float dt) {
314 int w = (int)getWidth();

Callers 1

profilePhasesMethod · 0.80

Calls 6

clampFunction · 0.85
noiseMethod · 0.80
getXMethod · 0.80
getYMethod · 0.80
s16x16Class · 0.50
rawMethod · 0.45

Tested by

no test coverage detected