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