FastLED 3.9.15
Loading...
Searching...
No Matches
spiral_matrix1.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 / 2; x++) {
26 for (int y = 0; y < e->num_y / 2; y++) {
27
28 e->animation.dist = e->distance[x][y];
29 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[0];
30 e->animation.z = 5;
31 e->animation.scale_x = 0.1;
32 e->animation.scale_y = 0.1;
33 e->animation.offset_z = 50 * e->move.linear[0];
34 e->animation.offset_x = 150 * e->move.directional[0];
35 e->animation.offset_y = 150 * e->move.directional[1];
36 float show1 = e->render_value(e->animation);
37
38 e->animation.dist = e->distance[x][y];
39 e->animation.angle = e->polar_theta[x][y] + 4 * e->move.noise_angle[1];
40 e->animation.z = 15;
41 e->animation.scale_x = 0.15;
42 e->animation.scale_y = 0.15;
43 e->animation.offset_z = 50 * e->move.linear[1];
44 e->animation.offset_x = 150 * e->move.directional[1];
45 e->animation.offset_y = 150 * e->move.directional[2];
46 float show2 = e->render_value(e->animation);
47
48 e->animation.dist = e->distance[x][y];
49 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[2];
50 e->animation.z = 25;
51 e->animation.scale_x = 0.1;
52 e->animation.scale_y = 0.1;
53 e->animation.offset_z = 50 * e->move.linear[2];
54 e->animation.offset_x = 150 * e->move.directional[2];
55 e->animation.offset_y = 150 * e->move.directional[3];
56 float show3 = e->render_value(e->animation);
57
58 e->animation.dist = e->distance[x][y];
59 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[3];
60 e->animation.z = 35;
61 e->animation.scale_x = 0.15;
62 e->animation.scale_y = 0.15;
63 e->animation.offset_z = 50 * e->move.linear[3];
64 e->animation.offset_x = 150 * e->move.directional[3];
65 e->animation.offset_y = 150 * e->move.directional[4];
66 float show4 = e->render_value(e->animation);
67
68 e->animation.dist = e->distance[x][y];
69 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[4];
70 e->animation.z = 45;
71 e->animation.scale_x = 0.2;
72 e->animation.scale_y = 0.2;
73 e->animation.offset_z = 50 * e->move.linear[4];
74 e->animation.offset_x = 150 * e->move.directional[4];
75 e->animation.offset_y = 150 * e->move.directional[5];
76 float show5 = e->render_value(e->animation);
77
78 e->pixel.red = show1 + show2;
79 e->pixel.green = show3 + show4;
80 e->pixel.blue = show5;
81
82 e->pixel = e->rgb_sanity_check(e->pixel);
83 e->setPixelColorInternal(x, y, e->pixel);
84
85 e->setPixelColorInternal((e->num_x - 1) - x, y, e->pixel);
86 e->setPixelColorInternal((e->num_x - 1) - x, (e->num_y - 1) - y, e->pixel);
87 e->setPixelColorInternal(x, (e->num_y - 1) - y, e->pixel);
88 }
89 }
90}
91
92
93// ============================================================================
94// Fixed-Point Implementation of SpiralMatrix1
95// ============================================================================
96
98 auto *e = ctx.mEngine.get();
99 e->get_ready();
100 mState.ensureCache(e);
101 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
102 const fl::u8 *perm = PERLIN_NOISE;
103
104 e->timings.master_speed = 0.02;
105 e->timings.ratio[0] = 0.0025;
106 e->timings.ratio[1] = 0.0027;
107 e->timings.ratio[2] = 0.0031;
108 e->timings.ratio[3] = 0.0033;
109 e->timings.ratio[4] = 0.0036;
110 e->timings.ratio[5] = 0.0039;
111
112 e->calculate_oscillators(e->timings);
113
114 for (int x = 0; x < e->num_x / 2; x++) {
115 for (int y = 0; y < e->num_y / 2; y++) {
116
117 e->animation.dist = e->distance[x][y];
118 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[0];
119 e->animation.z = 5;
120 e->animation.scale_x = 0.1;
121 e->animation.scale_y = 0.1;
122 e->animation.offset_z = 50 * e->move.linear[0];
123 e->animation.offset_x = 150 * e->move.directional[0];
124 e->animation.offset_y = 150 * e->move.directional[1];
125 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
126
127 e->animation.dist = e->distance[x][y];
128 e->animation.angle = e->polar_theta[x][y] + 4 * e->move.noise_angle[1];
129 e->animation.z = 15;
130 e->animation.scale_x = 0.15;
131 e->animation.scale_y = 0.15;
132 e->animation.offset_z = 50 * e->move.linear[1];
133 e->animation.offset_x = 150 * e->move.directional[1];
134 e->animation.offset_y = 150 * e->move.directional[2];
135 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
136
137 e->animation.dist = e->distance[x][y];
138 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[2];
139 e->animation.z = 25;
140 e->animation.scale_x = 0.1;
141 e->animation.scale_y = 0.1;
142 e->animation.offset_z = 50 * e->move.linear[2];
143 e->animation.offset_x = 150 * e->move.directional[2];
144 e->animation.offset_y = 150 * e->move.directional[3];
145 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
146
147 e->animation.dist = e->distance[x][y];
148 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[3];
149 e->animation.z = 35;
150 e->animation.scale_x = 0.15;
151 e->animation.scale_y = 0.15;
152 e->animation.offset_z = 50 * e->move.linear[3];
153 e->animation.offset_x = 150 * e->move.directional[3];
154 e->animation.offset_y = 150 * e->move.directional[4];
155 float show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
156
157 e->animation.dist = e->distance[x][y];
158 e->animation.angle = e->polar_theta[x][y] + 5 * e->move.noise_angle[4];
159 e->animation.z = 45;
160 e->animation.scale_x = 0.2;
161 e->animation.scale_y = 0.2;
162 e->animation.offset_z = 50 * e->move.linear[4];
163 e->animation.offset_x = 150 * e->move.directional[4];
164 e->animation.offset_y = 150 * e->move.directional[5];
165 float show5 = render_value_fp_from_float(e->animation, fade_lut, perm);
166
167 e->pixel.red = show1 + show2;
168 e->pixel.green = show3 + show4;
169 e->pixel.blue = show5;
170
171 e->pixel = e->rgb_sanity_check(e->pixel);
172 e->setPixelColorInternal(x, y, e->pixel);
173
174 e->setPixelColorInternal((e->num_x - 1) - x, y, e->pixel);
175 e->setPixelColorInternal((e->num_x - 1) - x, (e->num_y - 1) - y, e->pixel);
176 e->setPixelColorInternal(x, (e->num_y - 1) - y, e->pixel);
177 }
178 }
179}
180
181} // namespace fl
182
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