FastLED 3.9.15
Loading...
Searching...
No Matches
wave.cpp
Go to the documentation of this file.
1
2#include "FastLED.h"
3#include "wave.h"
4
5DEFINE_GRADIENT_PALETTE(electricBlueFirePal){
6 0, 0, 0, 0, // Black
7 32, 0, 0, 70, // Dark blue
8 128, 20, 57, 255, // Electric blue
9 255, 255, 255, 255 // White
10};
11
12DEFINE_GRADIENT_PALETTE(electricGreenFirePal){
13 0, 0, 0, 0, // black
14 8, 128, 64, 64, // green
15 16, 255, 222, 222, // red
16 64, 255, 255, 255, // white
17 255, 255, 255, 255 // white
18};
19
23 out.half_duplex = true;
24 out.auto_updates = true;
25 out.speed = 0.18f;
26 out.dampening = 9.0f;
27 out.crgbMap = fl::make_shared<fl::WaveCrgbGradientMap>(electricBlueFirePal);
28 return out;
29}
30
34 out.half_duplex = true;
35 out.auto_updates = true;
36 out.speed = 0.25f;
37 out.dampening = 3.0f;
38 out.crgbMap = fl::make_shared<fl::WaveCrgbGradientMap>(electricGreenFirePal);
39 return out;
40}
41
43 // only apply complex xymap as the last step after compositiing.
44 fl::XYMap xy_rect =
45 fl::XYMap::constructRectangularGrid(xymap.getWidth(), xymap.getHeight());
46 fl::Blend2dPtr fxBlend =
47 fl::make_shared<fl::Blend2d>(xymap); // Final transformation goes to the blend stack.
48 int width = xymap.getWidth();
49 int height = xymap.getHeight();
50 fl::XYMap xyRect(width, height, false);
51 fl::WaveFx::Args args_lower = CreateArgsLower();
52 fl::WaveFx::Args args_upper = CreateArgsUpper();
53 fl::WaveFxPtr wave_fx_low = fl::make_shared<fl::WaveFx>(xy_rect, args_lower);
54 fl::WaveFxPtr wave_fx_high = fl::make_shared<fl::WaveFx>(xy_rect, args_upper);
55 fl::Blend2dPtr blend_stack = fl::make_shared<fl::Blend2d>(xymap);
56 blend_stack->add(wave_fx_low);
57 blend_stack->add(wave_fx_high);
58 WaveEffect out = {
59 .wave_fx_low = wave_fx_low,
60 .wave_fx_high = wave_fx_high,
61 .blend_stack = blend_stack,
62 };
63
64 return out;
65}
XYMap xymap
WaveEffect NewWaveSimulation2D(const fl::XYMap &xymap)
Definition wave.cpp:42
fl::WaveFx::Args CreateArgsUpper()
Definition wave.cpp:31
fl::WaveFx::Args CreateArgsLower()
Definition wave.cpp:20
WaveFxArgs Args
Definition wave.h:168
static XYMap constructRectangularGrid(u16 width, u16 height, u16 offset=0) FL_NOEXCEPT
Definition xymap.cpp.hpp:35
#define DEFINE_GRADIENT_PALETTE(X)
shared_ptr< T > make_shared(Args &&... args) FL_NOEXCEPT
Definition shared_ptr.h:414
float speed
Wave propagation speed (0.0-1.0, typical: 0.1-0.3)
Definition wave.h:126
WaveCrgbMapPtr crgbMap
Custom color mapper (nullptr uses default grayscale)
Definition wave.h:134
bool auto_updates
If true, simulation advances automatically in draw()
Definition wave.h:124
SuperSample factor
Supersampling quality (SUPER_SAMPLE_2X recommended for balance)
Definition wave.h:120
float dampening
Energy dampening factor (higher = faster decay, typical: 3-10)
Definition wave.h:128
bool half_duplex
If true, constrains waves to positive values only.
Definition wave.h:122