FastLED 3.9.15
Loading...
Searching...
No Matches
wave.cpp
Go to the documentation of this file.
1
2#include "wave.h"
3#include "FastLED.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
21 WaveFx::Args out;
22 out.factor = SuperSample::SUPER_SAMPLE_2X;
23 out.half_duplex = true;
24 out.auto_updates = true;
25 out.speed = 0.18f;
26 out.dampening = 9.0f;
27 out.crgbMap = WaveCrgbGradientMapPtr::New(electricBlueFirePal);
28 return out;
29}
30
32 WaveFx::Args out;
33 out.factor = SuperSample::SUPER_SAMPLE_2X;
34 out.half_duplex = true;
35 out.auto_updates = true;
36 out.speed = 0.25f;
37 out.dampening = 3.0f;
38 out.crgbMap = WaveCrgbGradientMapPtr::New(electricGreenFirePal);
39 return out;
40}
41
43 // only apply complex xymap as the last step after compositiing.
44 XYMap xy_rect =
45 XYMap::constructRectangularGrid(xymap.getWidth(), xymap.getHeight());
46 Blend2dPtr fxBlend =
47 NewPtr<Blend2d>(xymap); // Final transformation goes to the blend stack.
48 int width = xymap.getWidth();
49 int height = xymap.getHeight();
50 XYMap xyRect(width, height, false);
51 WaveFx::Args args_lower = CreateArgsLower();
52 WaveFx::Args args_upper = CreateArgsUpper();
53 WaveFxPtr wave_fx_low = NewPtr<WaveFx>(xy_rect, args_lower);
54 WaveFxPtr wave_fx_high = NewPtr<WaveFx>(xy_rect, args_upper);
55 Blend2dPtr blend_stack = NewPtr<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(WIDTH, HEIGHT, SERPENTINE)
central include file for FastLED, defines the CFastLED class/object
Blend2d fxBlend(xyMap)
XYMap xyRect(WIDTH, HEIGHT, false)
static XYMap constructRectangularGrid(uint16_t width, uint16_t height, uint16_t offset=0)
Definition xymap.cpp:36
WaveFxArgs Args
Definition wave.h:79
#define DEFINE_GRADIENT_PALETTE(X)
Defines a static RGB palette very compactly using a series of connected color gradients.
Definition colorutils.h:102
WaveEffect NewWaveSimulation2D(const XYMap xymap)
Definition wave.cpp:42
WaveFx::Args CreateArgsLower()
Definition wave.cpp:20
WaveFx::Args CreateArgsUpper()
Definition wave.cpp:31
Ptr< T > NewPtr(Args... args)
Definition ptr.h:451
float speed
Definition wave.h:71
WaveCrgbMapPtr crgbMap
Definition wave.h:73
bool auto_updates
Definition wave.h:70
SuperSample factor
Definition wave.h:68
float dampening
Definition wave.h:72
bool half_duplex
Definition wave.h:69