FastLED 3.9.15
Loading...
Searching...
No Matches
hot_blob.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14 e->run_default_oscillators(0.001);
15
16 for (int x = 0; x < e->num_x; x++) {
17 for (int y = 0; y < e->num_y; y++) {
18 e->animation.dist = e->distance[x][y];
19 e->animation.angle = e->polar_theta[x][y];
20
21 e->animation.scale_x = 0.07 + e->move.directional[0] * 0.002;
22 e->animation.scale_y = 0.07;
23
24 e->animation.offset_y = -e->move.linear[0];
25 e->animation.offset_x = 0;
26 e->animation.offset_z = 0;
27
28 e->animation.z = 0;
29 e->animation.low_limit = -1;
30 float show1 = e->render_value(e->animation);
31
32 e->animation.offset_y = -e->move.linear[1];
33 float show3 = e->render_value(e->animation);
34
35 e->animation.offset_x = show3 / 20;
36 e->animation.offset_y = -e->move.linear[0] / 2 + show1 / 70;
37 e->animation.low_limit = 0;
38 float show2 = e->render_value(e->animation);
39
40 e->animation.offset_x = show3 / 20;
41 e->animation.offset_y = -e->move.linear[0] / 2 + show1 / 70;
42 e->animation.z = 100;
43 float show4 = e->render_value(e->animation);
44
45 float radius = e->radial_filter_radius;
46 float radial = (radius - e->animation.dist) / e->animation.dist;
47
48 float linear = (y + 1) / (e->num_y - 1.f);
49
50 e->pixel.red = radial * show2;
51 e->pixel.green = linear * radial * 0.3 * (show2 - show4);
52 e->pixel.blue = 0;
53
54 e->pixel = e->rgb_sanity_check(e->pixel);
55 e->setPixelColorInternal(x, y, e->pixel);
56 }
57 }
58}
59
60
61// ============================================================================
62// Fixed-Point Implementation of Hot_Blob
63// ============================================================================
64
66 auto *e = ctx.mEngine.get();
67 e->get_ready();
68 mState.ensureCache(e);
69 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
70 const fl::u8 *perm = PERLIN_NOISE;
71 e->run_default_oscillators(0.001);
72
73 for (int x = 0; x < e->num_x; x++) {
74 for (int y = 0; y < e->num_y; y++) {
75 e->animation.dist = e->distance[x][y];
76 e->animation.angle = e->polar_theta[x][y];
77
78 e->animation.scale_x = 0.07 + e->move.directional[0] * 0.002;
79 e->animation.scale_y = 0.07;
80
81 e->animation.offset_y = -e->move.linear[0];
82 e->animation.offset_x = 0;
83 e->animation.offset_z = 0;
84
85 e->animation.z = 0;
86 e->animation.low_limit = -1;
87 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
88
89 e->animation.offset_y = -e->move.linear[1];
90 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
91
92 e->animation.offset_x = show3 / 20;
93 e->animation.offset_y = -e->move.linear[0] / 2 + show1 / 70;
94 e->animation.low_limit = 0;
95 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
96
97 e->animation.offset_x = show3 / 20;
98 e->animation.offset_y = -e->move.linear[0] / 2 + show1 / 70;
99 e->animation.z = 100;
100 float show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
101
102 float radius = e->radial_filter_radius;
103 float radial = (radius - e->animation.dist) / e->animation.dist;
104
105 float linear = (y + 1) / (e->num_y - 1.f);
106
107 e->pixel.red = radial * show2;
108 e->pixel.green = linear * radial * 0.3 * (show2 - show4);
109 e->pixel.blue = 0;
110
111 e->pixel = e->rgb_sanity_check(e->pixel);
112 e->setPixelColorInternal(x, y, e->pixel);
113 }
114 }
115}
116
117} // namespace fl
118
FPVizState mState
Definition hot_blob.h:22
void draw(Context &ctx) override
void draw(Context &ctx) override
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