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