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