FastLED 3.9.15
Loading...
Searching...
No Matches
rgb_blobs.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
15 e->timings.master_speed = 0.2;
16 e->timings.ratio[0] = 0.0025;
17 e->timings.ratio[1] = 0.0027;
18 e->timings.ratio[2] = 0.0031;
19 e->timings.ratio[3] = 0.0033;
20 e->timings.ratio[4] = 0.0036;
21 e->timings.ratio[5] = 0.0039;
22
23 e->calculate_oscillators(e->timings);
24
25 for (int x = 0; x < e->num_x; x++) {
26 for (int y = 0; y < e->num_y; y++) {
27 e->animation.dist = e->distance[x][y];
28 e->animation.angle = e->polar_theta[x][y] + e->move.radial[0] +
29 e->move.noise_angle[0] + e->move.noise_angle[3];
30 e->animation.z = (fl::sqrtf(e->animation.dist));
31 e->animation.scale_x = 0.1;
32 e->animation.scale_y = 0.1;
33 e->animation.offset_z = 10;
34 e->animation.offset_x = 10 * e->move.linear[0];
35 float show1 = e->render_value(e->animation);
36
37 e->animation.angle = e->polar_theta[x][y] + e->move.radial[1] +
38 e->move.noise_angle[1] + e->move.noise_angle[4];
39 e->animation.offset_x = 11 * e->move.linear[1];
40 e->animation.offset_z = 100;
41 float show2 = e->render_value(e->animation);
42
43 e->animation.angle = e->polar_theta[x][y] + e->move.radial[2] +
44 e->move.noise_angle[2] + e->move.noise_angle[5];
45 e->animation.offset_x = 12 * e->move.linear[2];
46 e->animation.offset_z = 300;
47 float show3 = e->render_value(e->animation);
48
49 float radius = e->radial_filter_radius;
50 float radial = (radius - e->distance[x][y]) / e->distance[x][y];
51
52 e->pixel.red = radial * show1;
53 e->pixel.green = radial * show2;
54 e->pixel.blue = radial * show3;
55
56 e->pixel = e->rgb_sanity_check(e->pixel);
57 e->setPixelColorInternal(x, y, e->pixel);
58 }
59 }
60}
61
62
63// ============================================================================
64// Fixed-Point Implementation of RGB_Blobs
65// ============================================================================
66
68 auto *e = ctx.mEngine.get();
69 e->get_ready();
70 mState.ensureCache(e);
71 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
72 const fl::u8 *perm = PERLIN_NOISE;
73
74 e->timings.master_speed = 0.2;
75 e->timings.ratio[0] = 0.0025;
76 e->timings.ratio[1] = 0.0027;
77 e->timings.ratio[2] = 0.0031;
78 e->timings.ratio[3] = 0.0033;
79 e->timings.ratio[4] = 0.0036;
80 e->timings.ratio[5] = 0.0039;
81
82 e->calculate_oscillators(e->timings);
83
84 for (int x = 0; x < e->num_x; x++) {
85 for (int y = 0; y < e->num_y; y++) {
86 e->animation.dist = e->distance[x][y];
87 e->animation.angle = e->polar_theta[x][y] + e->move.radial[0] +
88 e->move.noise_angle[0] + e->move.noise_angle[3];
89 e->animation.z = (fl::sqrtf(e->animation.dist));
90 e->animation.scale_x = 0.1;
91 e->animation.scale_y = 0.1;
92 e->animation.offset_z = 10;
93 e->animation.offset_x = 10 * e->move.linear[0];
94 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
95
96 e->animation.angle = e->polar_theta[x][y] + e->move.radial[1] +
97 e->move.noise_angle[1] + e->move.noise_angle[4];
98 e->animation.offset_x = 11 * e->move.linear[1];
99 e->animation.offset_z = 100;
100 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
101
102 e->animation.angle = e->polar_theta[x][y] + e->move.radial[2] +
103 e->move.noise_angle[2] + e->move.noise_angle[5];
104 e->animation.offset_x = 12 * e->move.linear[2];
105 e->animation.offset_z = 300;
106 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
107
108 float radius = e->radial_filter_radius;
109 float radial = (radius - e->distance[x][y]) / e->distance[x][y];
110
111 e->pixel.red = radial * show1;
112 e->pixel.green = radial * show2;
113 e->pixel.blue = radial * show3;
114
115 e->pixel = e->rgb_sanity_check(e->pixel);
116 e->setPixelColorInternal(x, y, e->pixel);
117 }
118 }
119}
120
121} // namespace fl
122
void draw(Context &ctx) override
FPVizState mState
Definition rgb_blobs.h:22
void draw(Context &ctx) override
unsigned char u8
Definition s16x16x4.h:132
T * assume_aligned(T *ptr) FL_NOEXCEPT
Definition s16x16x4.h:126
float sqrtf(float value) FL_NOEXCEPT
Definition math.h:453
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