FastLED 3.10.8
Loading...
Searching...
No Matches
lava1.cpp.hpp
Go to the documentation of this file.
5#include "fl/stl/noexcept.h"
6
9
10namespace fl {
11
13 auto *e = ctx.mEngine.get();
14 e->get_ready();
15
16 e->timings.master_speed = 0.0015;
17 e->timings.ratio[0] = 4;
18 e->timings.ratio[1] = 1;
19 e->timings.ratio[2] = 1;
20 e->timings.ratio[3] = 0.05;
21 e->timings.ratio[4] = 0.6;
22 e->timings.offset[0] = 0;
23 e->timings.offset[1] = 100;
24 e->timings.offset[2] = 200;
25 e->timings.offset[3] = 300;
26 e->timings.offset[4] = 400;
27
28 e->calculate_oscillators(e->timings);
29
30 for (int x = 0; x < e->num_x; x++) {
31 for (int y = 0; y < e->num_y; y++) {
32 e->animation.dist = e->distance[x][y] * 0.8;
33 e->animation.angle = e->polar_theta[x][y];
34 e->animation.scale_x = 0.15;
35 e->animation.scale_y = 0.12;
36 e->animation.scale_z = 0.01;
37 e->animation.offset_y = -e->move.linear[0];
38 e->animation.offset_x = 0;
39 e->animation.offset_z = 0;
40 e->animation.z = 30;
41 float show1 = e->render_value(e->animation);
42
43 e->animation.offset_y = -e->move.linear[1];
44 e->animation.scale_x = 0.15;
45 e->animation.scale_y = 0.12;
46 e->animation.offset_x = show1 / 100;
47 e->animation.offset_y += show1 / 100;
48 float show2 = e->render_value(e->animation);
49
50 e->animation.offset_y = -e->move.linear[2];
51 e->animation.scale_x = 0.15;
52 e->animation.scale_y = 0.12;
53 e->animation.offset_x = show2 / 100;
54 e->animation.offset_y += show2 / 100;
55 float show3 = e->render_value(e->animation);
56
57 float linear = (y) / (e->num_y - 1.f);
58
59 e->pixel.red = linear * show2;
60 e->pixel.green = 0.1 * linear * (show2 - show3);
61 e->pixel.blue = 0;
62
63 e->pixel = e->rgb_sanity_check(e->pixel);
64 e->setPixelColorInternal(x, y, e->pixel);
65 }
66 }
67}
68
69
70// ============================================================================
71// Fixed-Point Implementation of Lava1
72// ============================================================================
73
75 auto *e = ctx.mEngine.get();
76 e->get_ready();
77 mState.ensureCache(e);
78 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
79 const fl::u8 *perm = PERLIN_NOISE;
80
81 e->timings.master_speed = 0.0015;
82 e->timings.ratio[0] = 4;
83 e->timings.ratio[1] = 1;
84 e->timings.ratio[2] = 1;
85 e->timings.ratio[3] = 0.05;
86 e->timings.ratio[4] = 0.6;
87 e->timings.offset[0] = 0;
88 e->timings.offset[1] = 100;
89 e->timings.offset[2] = 200;
90 e->timings.offset[3] = 300;
91 e->timings.offset[4] = 400;
92
93 e->calculate_oscillators(e->timings);
94
95 for (int x = 0; x < e->num_x; x++) {
96 for (int y = 0; y < e->num_y; y++) {
97 e->animation.dist = e->distance[x][y] * 0.8;
98 e->animation.angle = e->polar_theta[x][y];
99 e->animation.scale_x = 0.15;
100 e->animation.scale_y = 0.12;
101 e->animation.scale_z = 0.01;
102 e->animation.offset_y = -e->move.linear[0];
103 e->animation.offset_x = 0;
104 e->animation.offset_z = 0;
105 e->animation.z = 30;
106 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
107
108 e->animation.offset_y = -e->move.linear[1];
109 e->animation.scale_x = 0.15;
110 e->animation.scale_y = 0.12;
111 e->animation.offset_x = show1 / 100;
112 e->animation.offset_y += show1 / 100;
113 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
114
115 e->animation.offset_y = -e->move.linear[2];
116 e->animation.scale_x = 0.15;
117 e->animation.scale_y = 0.12;
118 e->animation.offset_x = show2 / 100;
119 e->animation.offset_y += show2 / 100;
120 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
121
122 float linear = (y) / (e->num_y - 1.f);
123
124 e->pixel.red = linear * show2;
125 e->pixel.green = 0.1 * linear * (show2 - show3);
126 e->pixel.blue = 0;
127
128 e->pixel = e->rgb_sanity_check(e->pixel);
129 e->setPixelColorInternal(x, y, e->pixel);
130 }
131 }
132}
133
134} // namespace fl
135
FPVizState mState
Definition lava1.h:23
void draw(Context &ctx) FL_NO_EXCEPT override
Definition lava1.cpp.hpp:74
void draw(Context &ctx) FL_NO_EXCEPT override
Definition lava1.cpp.hpp:12
#define FL_OPTIMIZATION_LEVEL_O3_BEGIN
#define FL_FAST_MATH_BEGIN
#define FL_FAST_MATH_END
#define FL_OPTIMIZATION_LEVEL_O3_END
T * assume_aligned(T *ptr) FL_NO_EXCEPT
Definition s16x16x4.h:126
unsigned char u8
Definition stdint.h:131
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
FASTLED_FORCE_INLINE fl::i32 render_value_fp_from_float(const render_parameters &anim, const fl::i32 *fade_lut, const fl::u8 *perm) FL_NO_EXCEPT
Base definition for an LED controller.
Definition crgb.hpp:179