FastLED 3.10.8
Loading...
Searching...
No Matches
caleido3.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.004;
17 e->timings.ratio[0] = 0.02;
18 e->timings.ratio[1] = 0.03;
19 e->timings.ratio[2] = 0.04;
20 e->timings.ratio[3] = 0.05;
21 e->timings.ratio[4] = 0.6;
22 e->timings.offset[0] = 0;
23 e->timings.offset[1] = 100;
24 e->timings.offset[2] = 200;
25 e->timings.offset[3] = 300;
26 e->timings.offset[4] = 400;
27
28 e->calculate_oscillators(e->timings);
29
30 for (int x = 0; x < e->num_x; x++) {
31 for (int y = 0; y < e->num_y; y++) {
32 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[0]) / 3;
33 e->animation.angle = 2 * e->polar_theta[x][y] +
34 3 * e->move.noise_angle[0] + e->move.radial[4];
35 e->animation.scale_x = 0.1;
36 e->animation.scale_y = 0.1;
37 e->animation.scale_z = 0.1;
38 e->animation.offset_y = 2 * e->move.linear[0];
39 e->animation.offset_x = 2 * e->move.linear[1];
40 e->animation.offset_z = 0;
41 e->animation.z = e->move.linear[0];
42 float show1 = e->render_value(e->animation);
43
44 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[1]) / 3;
45 e->animation.angle = 2 * e->polar_theta[x][y] +
46 3 * e->move.noise_angle[1] + e->move.radial[4];
47 e->animation.offset_x = 2 * e->move.linear[1];
48 e->animation.offset_y = show1 / 20.0;
49 e->animation.z = e->move.linear[1];
50 float show2 = e->render_value(e->animation);
51
52 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[2]) / 3;
53 e->animation.angle = 2 * e->polar_theta[x][y] +
54 3 * e->move.noise_angle[2] + e->move.radial[4];
55 e->animation.offset_y = 2 * e->move.linear[2];
56 e->animation.offset_x = show2 / 20.0;
57 e->animation.z = e->move.linear[2];
58 float show3 = e->render_value(e->animation);
59
60 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[3]) / 3;
61 e->animation.angle = 2 * e->polar_theta[x][y] +
62 3 * e->move.noise_angle[3] + e->move.radial[4];
63 e->animation.offset_x = 2 * e->move.linear[3];
64 e->animation.offset_y = show3 / 20.0;
65 e->animation.z = e->move.linear[3];
66 float show4 = e->render_value(e->animation);
67
68 float radius = e->radial_filter_radius;
69
70 e->pixel.red = show1 * (y + 1) / e->num_y;
71 e->pixel.green = show3 * e->distance[x][y] / 10;
72 e->pixel.blue = (show2 + show4) / 2;
73 if (e->distance[x][y] > radius) {
74 e->pixel.red = 0;
75 e->pixel.green = 0;
76 e->pixel.blue = 0;
77 }
78
79 e->pixel = e->rgb_sanity_check(e->pixel);
80 e->setPixelColorInternal(x, y, e->pixel);
81 }
82 }
83}
84
85
86// ============================================================================
87// Fixed-Point Implementation of Caleido3
88// ============================================================================
89
91 auto *e = ctx.mEngine.get();
92 e->get_ready();
93 mState.ensureCache(e);
94 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
95 const fl::u8 *perm = PERLIN_NOISE;
96
97 e->timings.master_speed = 0.004;
98 e->timings.ratio[0] = 0.02;
99 e->timings.ratio[1] = 0.03;
100 e->timings.ratio[2] = 0.04;
101 e->timings.ratio[3] = 0.05;
102 e->timings.ratio[4] = 0.6;
103 e->timings.offset[0] = 0;
104 e->timings.offset[1] = 100;
105 e->timings.offset[2] = 200;
106 e->timings.offset[3] = 300;
107 e->timings.offset[4] = 400;
108
109 e->calculate_oscillators(e->timings);
110
111 for (int x = 0; x < e->num_x; x++) {
112 for (int y = 0; y < e->num_y; y++) {
113 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[0]) / 3;
114 e->animation.angle = 2 * e->polar_theta[x][y] +
115 3 * e->move.noise_angle[0] + e->move.radial[4];
116 e->animation.scale_x = 0.1;
117 e->animation.scale_y = 0.1;
118 e->animation.scale_z = 0.1;
119 e->animation.offset_y = 2 * e->move.linear[0];
120 e->animation.offset_x = 2 * e->move.linear[1];
121 e->animation.offset_z = 0;
122 e->animation.z = e->move.linear[0];
123 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
124
125 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[1]) / 3;
126 e->animation.angle = 2 * e->polar_theta[x][y] +
127 3 * e->move.noise_angle[1] + e->move.radial[4];
128 e->animation.offset_x = 2 * e->move.linear[1];
129 e->animation.offset_y = show1 / 20.0;
130 e->animation.z = e->move.linear[1];
131 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
132
133 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[2]) / 3;
134 e->animation.angle = 2 * e->polar_theta[x][y] +
135 3 * e->move.noise_angle[2] + e->move.radial[4];
136 e->animation.offset_y = 2 * e->move.linear[2];
137 e->animation.offset_x = show2 / 20.0;
138 e->animation.z = e->move.linear[2];
139 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
140
141 e->animation.dist = e->distance[x][y] * (2 + e->move.directional[3]) / 3;
142 e->animation.angle = 2 * e->polar_theta[x][y] +
143 3 * e->move.noise_angle[3] + e->move.radial[4];
144 e->animation.offset_x = 2 * e->move.linear[3];
145 e->animation.offset_y = show3 / 20.0;
146 e->animation.z = e->move.linear[3];
147 float show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
148
149 float radius = e->radial_filter_radius;
150
151 e->pixel.red = show1 * (y + 1) / e->num_y;
152 e->pixel.green = show3 * e->distance[x][y] / 10;
153 e->pixel.blue = (show2 + show4) / 2;
154 if (e->distance[x][y] > radius) {
155 e->pixel.red = 0;
156 e->pixel.green = 0;
157 e->pixel.blue = 0;
158 }
159
160 e->pixel = e->rgb_sanity_check(e->pixel);
161 e->setPixelColorInternal(x, y, e->pixel);
162 }
163 }
164}
165
166} // namespace fl
167
void draw(Context &ctx) FL_NO_EXCEPT override
FPVizState mState
Definition caleido3.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
Base definition for an LED controller.
Definition crgb.hpp:179