41 for (u16 i = 0; i <
size; ++i) {
46 for (u16 i = 0; i <
size; ++i) {
54 if (
width <= 0.0f || amplitude == 0.0f ||
mSize == 0) {
57 const float halfWidth =
width * 0.5f;
60 static_cast<int>(
fl::ceilf(center + halfWidth)));
61 for (
int i = iStart; i <= iEnd; ++i) {
62 float t = (
static_cast<float>(i) - (center - halfWidth)) /
width;
70 float u = (
t - 0.5f) / 0.2f;
81 for (u16 i = 0; i <
mSize; ++i) {
91 for (u16 i = 0; i <
mSize; ++i) {
175 count = (w * h + 3) & ~3;
309 float noise(
float x,
float y)
const;
314 return t *
t *
t * (
t * (
t * 6.0f - 15.0f) + 10.0f);
316 static float lerp(
float a,
float b,
float t) {
317 return a +
t * (b - a);
319 static float grad(
int h,
float x,
float y);
328 static float fmodPos(
float x,
float m);
329 static float clampf(
float v,
float lo,
float hi);
337 void drawDot(
float cx,
float cy,
float diam,
339 void drawAALine(
float x0,
float y0,
float x1,
float y1,
378 static i32
clamp_q16(i32 v, i32 lo, i32 hi);
uint8_t noise[NUM_LAYERS][WIDTH][HEIGHT]
fl::UIButton noisePunch("NoisePunch")
fl::UISlider colorShift("Color Shift", 0.04f, 0.0f, 0.5f, 0.01f)
Alignment macros and utilities for FastLED.
void setNoiseFrequency(float freq)
void setColorShift(float speed)
void noisePunchX(float center, float width, float amplitude=1.0f, BumpShape shape=BumpShape::HalfSine)
Trigger a noise punch on the X axis (columns).
void setFlowSpeedX(float speed)
void setFlowSpeedY(float speed)
void noisePunchY(float center, float width, float amplitude=1.0f, BumpShape shape=BumpShape::HalfSine)
Trigger a noise punch on the Y axis (rows).
void setNoiseFrequencyX(float freq)
void setEndpointSpeed(float speed)
void setDotCount(int count)
void setReverseXProfile(bool rev)
void setPersistence(float halfLife)
void setFlowAmplitudeX(float amp)
void draw(DrawContext context) override
Handles timing, then delegates to drawImpl().
const NoiseBias2D & noiseBias() const
~FlowField() FL_NOEXCEPT override=default
void setSpeed(float speed)
Set time speed/scale (1.0 = normal, 0.5 = half speed, etc.)
virtual void drawImpl(DrawContext context, u32 dt_ms, u32 t_ms)=0
Subclasses implement rendering given the time delta and total time.
const Params & getParams() const
FlowField(const XYMap &xyMap, const Params ¶ms=Params())
void setFlowShift(float shift)
void setNoiseFrequencyY(float freq)
void setEmitterMode(int mode)
NoiseBias2D & noiseBias()
void setShowFlowVectors(bool show)
void setFlowAmplitudeY(float amp)
int idx(int y, int x) const
void drawAALine(s16x16 x0, s16x16 y0, s16x16 x1, s16x16 y1, s16x16 t, s16x16 colorShift)
FlowFieldFP(const XYMap &xyMap, const Params ¶ms=Params())
fl::string fxName() const override
void drawDot(s16x16 cx, s16x16 cy, s16x16 diam, u8 cr, u8 cg, u8 cb)
static i32 clamp_q16(i32 v, i32 lo, i32 hi)
friend struct FlowFieldFPProfiler
void flowAdvect(i32 dt_raw)
void flowPrepare(s16x16 t)
static u8 q16_to_u8(i32 v)
void emitLissajousLine(s16x16 t)
void drawImpl(DrawContext context, u32 dt_ms, u32 t_ms) override
Subclasses implement rendering given the time delta and total time.
void emitOrbitalDots(s16x16 t)
static void initPerm256(u8 *perm, u32 seed)
void drawFlowVectors(fl::span< CRGB > leds)
Pure fixed-point (s16x16) flow field implementation for maximum speed.
static float fade(float t)
static float lerp(float a, float b, float t)
static float grad(int h, float x, float y)
fl::string fxName() const override
void drawAALine(float x0, float y0, float x1, float y1, float t, float colorShift)
fl::vector< float > mYProf
Per-row values; drives horizontal shift.
void drawDot(float cx, float cy, float diam, u8 cr, u8 cg, u8 cb)
void drawFlowVectors(fl::span< CRGB > leds)
static float clampf(float v, float lo, float hi)
FlowFieldFloat(const XYMap &xyMap, const Params ¶ms=Params())
void flowAdvect(float dt)
void drawImpl(DrawContext context, u32 dt_ms, u32 t_ms) override
Subclasses implement rendering given the time delta and total time.
fl::vector< float > mXProf
Per-column values; drives vertical shift.
void emitOrbitalDots(float t)
void flowPrepare(float t)
void emitLissajousLine(float t)
int idx(int y, int x) const
static float fmodPos(float x, float m)
Float-precision flow field implementation.
Abstract base class for 2D flow field effects.
u16 xyMap(u16 x, u16 y) const
void trigger(float center, float width, float amplitude, BumpShape shape=BumpShape::HalfSine)
Inject a shaped bump. Multiple triggers per frame accumulate additively.
void update(float dtSeconds)
Advance all filters by dt seconds.
fl::vector< float > mPending
NoiseBias1D(u16 size, float attackTau, float decayTau)
fl::vector< AttackDecayFilter< float > > mFilters
Per-position attack/decay bias for one axis.
const NoiseBias1D & y() const
float get(u16 x, u16 y) const
void update(float dtSeconds)
NoiseBias2D(u16 width, u16 height, float attackTau, float decayTau)
const NoiseBias1D & x() const
void triggerY(float center, float width, float amplitude, BumpShape shape=BumpShape::HalfSine)
void triggerX(float center, float width, float amplitude, BumpShape shape=BumpShape::HalfSine)
Two-axis attack/decay bias for 2D effects (per-column X + per-row Y).
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
float expf(float value) FL_NOEXCEPT
float floorf(float value) FL_NOEXCEPT
float sinf(float value) FL_NOEXCEPT
float ceilf(float value) FL_NOEXCEPT
BumpShape
Shape function for NoiseBias triggers.
@ HalfSine
sin(pi * t), smooth bell, zero at edges
@ Gaussian
exp(-0.5 * ((t-0.5)/sigma)^2), tighter peak
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NOEXCEPT
Base definition for an LED controller.
float flow_amp_y
Flow amplitude Y.
float flow_amp_x
Flow amplitude X.
float flow_speed_y
Noise scroll speed Y.
float color_shift
Color shift speed.
bool show_flow_vectors
Draw flow profiles as overlay.
bool reverse_x_profile
Reverse X profile (matches Python)
float endpoint_speed
Lissajous endpoint speed.
int emitter_mode
0=Lissajous, 1=Dots, 2=Both
float flow_shift
Pixel shift amount.
float flow_speed_x
Noise scroll speed X.
float persistence
Trail half-life in seconds.
float noise_freq_y
Noise frequency Y.
float noise_freq_x
Noise frequency X.
int dot_count
Number of orbital dots.
Configuration parameters for FlowField.
#define FASTLED_SHARED_PTR(type)
Representation of an 8-bit RGB pixel (Red, Green, Blue)
fl::vector< fl::i32 > y_prof
fl::vector< fl::i32 > x_prof
FlowFieldFPState() FL_NOEXCEPT
bool fade_lut_initialized
SoA (Structure-of-Arrays) state for FlowFieldFP.