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