FastLED 3.10.8
Loading...
Searching...
No Matches
rotating_blob.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.01;
17 e->timings.ratio[0] = 0.1;
18 e->timings.ratio[1] = 0.03;
19 e->timings.ratio[2] = 0.03;
20 e->timings.ratio[3] = 0.03;
21
22 e->timings.offset[1] = 10;
23 e->timings.offset[2] = 20;
24 e->timings.offset[3] = 30;
25
26 e->calculate_oscillators(e->timings);
27
28 for (int x = 0; x < e->num_x; x++) {
29 for (int y = 0; y < e->num_y; y++) {
30 e->animation.scale_x = 0.05;
31 e->animation.scale_y = 0.05;
32 e->animation.offset_x = 0;
33 e->animation.offset_y = 0;
34 e->animation.offset_z = 100;
35 e->animation.angle = e->polar_theta[x][y] + e->move.radial[0];
36 e->animation.dist = e->distance[x][y];
37 e->animation.z = e->move.linear[0];
38 e->animation.low_limit = -1;
39 float show1 = e->render_value(e->animation);
40
41 e->animation.angle =
42 e->polar_theta[x][y] - e->move.radial[1] + show1 / 512.0;
43 e->animation.dist = e->distance[x][y] * show1 / 255.0;
44 e->animation.low_limit = 0;
45 e->animation.z = e->move.linear[1];
46 float show2 = e->render_value(e->animation);
47
48 e->animation.angle =
49 e->polar_theta[x][y] - e->move.radial[2] + show1 / 512.0;
50 e->animation.dist = e->distance[x][y] * show1 / 220.0;
51 e->animation.z = e->move.linear[2];
52 float show3 = e->render_value(e->animation);
53
54 e->animation.angle =
55 e->polar_theta[x][y] - e->move.radial[3] + show1 / 512.0;
56 e->animation.dist = e->distance[x][y] * show1 / 200.0;
57 e->animation.z = e->move.linear[3];
58 float show4 = e->render_value(e->animation);
59
60 e->pixel.red = (show2 + show4) / 2;
61 e->pixel.green = show3 / 6;
62 e->pixel.blue = 0;
63
64 e->pixel = e->rgb_sanity_check(e->pixel);
65 e->setPixelColorInternal(x, y, e->pixel);
66 }
67 }
68}
69
70
71// ============================================================================
72// Fixed-Point Implementation of Rotating_Blob
73// ============================================================================
74
76 auto *e = ctx.mEngine.get();
77 e->get_ready();
78 mState.ensureCache(e);
79 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
80 const fl::u8 *perm = PERLIN_NOISE;
81
82 e->timings.master_speed = 0.01;
83 e->timings.ratio[0] = 0.1;
84 e->timings.ratio[1] = 0.03;
85 e->timings.ratio[2] = 0.03;
86 e->timings.ratio[3] = 0.03;
87
88 e->timings.offset[1] = 10;
89 e->timings.offset[2] = 20;
90 e->timings.offset[3] = 30;
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.scale_x = 0.05;
97 e->animation.scale_y = 0.05;
98 e->animation.offset_x = 0;
99 e->animation.offset_y = 0;
100 e->animation.offset_z = 100;
101 e->animation.angle = e->polar_theta[x][y] + e->move.radial[0];
102 e->animation.dist = e->distance[x][y];
103 e->animation.z = e->move.linear[0];
104 e->animation.low_limit = -1;
105 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
106
107 e->animation.angle =
108 e->polar_theta[x][y] - e->move.radial[1] + show1 / 512.0;
109 e->animation.dist = e->distance[x][y] * show1 / 255.0;
110 e->animation.low_limit = 0;
111 e->animation.z = e->move.linear[1];
112 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
113
114 e->animation.angle =
115 e->polar_theta[x][y] - e->move.radial[2] + show1 / 512.0;
116 e->animation.dist = e->distance[x][y] * show1 / 220.0;
117 e->animation.z = e->move.linear[2];
118 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
119
120 e->animation.angle =
121 e->polar_theta[x][y] - e->move.radial[3] + show1 / 512.0;
122 e->animation.dist = e->distance[x][y] * show1 / 200.0;
123 e->animation.z = e->move.linear[3];
124 float show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
125
126 e->pixel.red = (show2 + show4) / 2;
127 e->pixel.green = show3 / 6;
128 e->pixel.blue = 0;
129
130 e->pixel = e->rgb_sanity_check(e->pixel);
131 e->setPixelColorInternal(x, y, e->pixel);
132 }
133 }
134}
135
136} // namespace fl
137
void draw(Context &ctx) FL_NO_EXCEPT override
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
Base definition for an LED controller.
Definition crgb.hpp:179