FastLED 3.9.15
Loading...
Searching...
No Matches
fl::WaveFx Class Reference

Detailed Description

2D wave simulation effect with supersampling and gradient coloring

Creates realistic water-like wave effects on LED matrices. Features include:

  • Physics-based wave propagation using WaveSimulation2D
  • Supersampling for smooth, high-quality rendering
  • Configurable speed, dampening, and other physics parameters
  • Support for gradient/palette coloring or grayscale
  • Optional cylindrical wrapping on x-axis
  • Half-duplex mode for positive-only waves

Example usage:

XYMap xymap(16, 16);
args.speed = 0.18f;
args.dampening = 9.0f;
WaveFx wave(xymap, args);
// Trigger a wave at position (8, 8)
wave.setf(8, 8, 1.0f);
// In draw loop:
wave.draw(ctx);
fl::CRGB leds[NUM_LEDS]
XYMap xymap
::fl::DrawContext DrawContext
Definition fx.h:21
WaveFx(const XYMap &xymap, Args args=Args())
Construct wave effect with given coordinate mapping and parameters.
Definition wave.h:173
WaveFxArgs Args
Definition wave.h:168
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
corkscrew_args args
Definition old.h:149
See also
WaveSimulation2D for the underlying physics engine
examples/FxWave2d/FxWave2d.ino for a complete demonstration

Definition at line 166 of file wave.h.

#include <wave.h>

+ Inheritance diagram for fl::WaveFx:
+ Collaboration diagram for fl::WaveFx:

Public Types

using Args = WaveFxArgs
 
- Public Types inherited from fl::Fx
using DrawContext = ::fl::DrawContext
 

Public Member Functions

 WaveFx (const XYMap &xymap, Args args=Args())
 Construct wave effect with given coordinate mapping and parameters.
 
void addf (size_t x, size_t y, float value)
 Add wave amplitude to existing value at a position.
 
void draw (DrawContext context) override
 Render wave to LED array.
 
fl::string fxName () const override
 Get effect name.
 
LaplacianStencil getStencil () const FL_NOEXCEPT
 Get the currently active Laplacian stencil.
 
u8 getu8 (size_t x, size_t y) const
 Get wave amplitude as 8-bit value.
 
bool getUseChangeGrid () const
 Get current change grid tracking setting.
 
void setAutoUpdate (bool autoUpdate)
 Enable/disable automatic simulation updates.
 
void setCrgbMap (WaveCrgbMapPtr crgbMap)
 Set custom color mapping function.
 
void setDampening (float dampening)
 Set wave energy dampening.
 
void setEasingMode (U8EasingFunction mode)
 Set easing function for wave amplitude calculation.
 
void setf (size_t x, size_t y, float value)
 Set wave amplitude at a specific grid position.
 
void setHalfDuplex (bool on)
 Enable/disable half-duplex mode.
 
void setSpeed (float speed)
 Set wave propagation speed.
 
void setStencil (LaplacianStencil s) FL_NOEXCEPT
 Select the discrete Laplacian stencil.
 
void setSuperSample (SuperSample factor)
 Set supersampling quality level.
 
void setUseChangeGrid (bool enabled)
 Enable/disable change grid tracking optimization.
 
void setXCylindrical (bool on)
 Enable/disable cylindrical topology on x-axis.
 
void update ()
 Manually advance wave simulation by one step.
 
- Public Member Functions inherited from fl::Fx2d
 Fx2d (const XYMap &xyMap)
 
u16 getHeight () const
 
u16 getWidth () const
 
XYMapgetXYMap ()
 
const XYMapgetXYMap () const
 
void setXYMap (const XYMap &xyMap)
 
u16 xyMap (u16 x, u16 y) const
 
- Public Member Functions inherited from fl::Fx
 Fx (u16 numLeds)
 
u16 getNumLeds () const
 
virtual bool hasFixedFrameRate (float *fps) const
 
virtual void pause (fl::u32 now)
 
virtual void resume (fl::u32 now)
 

Public Attributes

bool mAutoUpdates = true
 
WaveCrgbMapPtr mCrgbMap
 
WaveSimulation2D mWaveSim
 

Additional Inherited Members

- Protected Member Functions inherited from fl::Fx
virtual ~Fx () FL_NOEXCEPT
 
- Protected Attributes inherited from fl::Fx2d
XYMap mXyMap
 
- Protected Attributes inherited from fl::Fx
u16 mNumLeds
 

The documentation for this class was generated from the following file: