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