FastLED 3.10.8
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);
CRGB leds[1]
XYMap xymap
::fl::DrawContext DrawContext
Definition fx.h:21
WaveFxArgs Args
Definition wave.h:179
WaveFx(const XYMap &xymap, Args args=Args()) FL_NO_EXCEPT
Construct wave effect with given coordinate mapping and parameters.
Definition wave.h:184
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
Definition shared_ptr.h:423
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
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 177 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()) FL_NO_EXCEPT
 Construct wave effect with given coordinate mapping and parameters.
 
void addf (size_t x, size_t y, float value) FL_NO_EXCEPT
 Add wave amplitude to existing value at a position.
 
void draw (DrawContext context) FL_NO_EXCEPT override
 Render wave to LED array.
 
fl::string fxName () const FL_NO_EXCEPT override
 Get effect name.
 
fl::u8 getOutputBlurAmount () const FL_NO_EXCEPT
 
fl::u8 getOutputBlurPasses () const FL_NO_EXCEPT
 
LaplacianStencil getStencil () const FL_NO_EXCEPT
 Get the currently active Laplacian stencil.
 
u8 getu8 (size_t x, size_t y) const FL_NO_EXCEPT
 Get wave amplitude as 8-bit value.
 
bool getUseChangeGrid () const FL_NO_EXCEPT
 Get current change grid tracking setting.
 
void setAutoUpdate (bool autoUpdate) FL_NO_EXCEPT
 Enable/disable automatic simulation updates.
 
void setCrgbMap (WaveCrgbMapPtr crgbMap) FL_NO_EXCEPT
 Set custom color mapping function.
 
void setDampening (float dampening) FL_NO_EXCEPT
 Set wave energy dampening.
 
void setEasingMode (U8EasingFunction mode) FL_NO_EXCEPT
 Set easing function for wave amplitude calculation.
 
void setf (size_t x, size_t y, float value) FL_NO_EXCEPT
 Set wave amplitude at a specific grid position.
 
void setHalfDuplex (bool on) FL_NO_EXCEPT
 Enable/disable half-duplex mode.
 
void setOutputBlur (fl::u8 amount, fl::u8 passes=1) FL_NO_EXCEPT
 Configure the post-process output blur (#3122 A4)
 
void setSpeed (float speed) FL_NO_EXCEPT
 Set wave propagation speed.
 
void setStencil (LaplacianStencil s) FL_NO_EXCEPT
 Select the discrete Laplacian stencil.
 
void setSuperSample (SuperSample factor) FL_NO_EXCEPT
 Set supersampling quality level.
 
void setUseChangeGrid (bool enabled) FL_NO_EXCEPT
 Enable/disable change grid tracking optimization.
 
void setXCylindrical (bool on) FL_NO_EXCEPT
 Enable/disable cylindrical topology on x-axis.
 
void update () FL_NO_EXCEPT
 Manually advance wave simulation by one step.
 
- Public Member Functions inherited from fl::Fx2d
 Fx2d (const XYMap &xyMap) FL_NO_EXCEPT
 
u16 getHeight () const FL_NO_EXCEPT
 
u16 getWidth () const FL_NO_EXCEPT
 
const XYMap & getXYMap () const FL_NO_EXCEPT
 
XYMap & getXYMap () FL_NO_EXCEPT
 
void setXYMap (const XYMap &xyMap) FL_NO_EXCEPT
 
u16 xyMap (u16 x, u16 y) const FL_NO_EXCEPT
 
- Public Member Functions inherited from fl::Fx
 Fx (u16 numLeds) FL_NO_EXCEPT
 
u16 getNumLeds () const FL_NO_EXCEPT
 
virtual bool hasFixedFrameRate (float *fps) const FL_NO_EXCEPT
 
virtual void pause (fl::u32 now) FL_NO_EXCEPT
 
virtual void resume (fl::u32 now) FL_NO_EXCEPT
 

Public Attributes

bool mAutoUpdates = true
 
WaveCrgbMapPtr mCrgbMap
 
fl::u8 mOutputBlurAmount = 0
 
fl::u8 mOutputBlurPasses = 1
 
WaveSimulation2D mWaveSim
 

Additional Inherited Members

- Protected Member Functions inherited from fl::Fx
virtual ~Fx () FL_NO_EXCEPT
 
- 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: