FastLED 3.10.8
Loading...
Searching...
No Matches
spiralus2.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.0015;
17 e->timings.ratio[0] = 1.5;
18 e->timings.ratio[1] = 2.3;
19 e->timings.ratio[2] = 3;
20 e->timings.ratio[3] = 0.05;
21 e->timings.ratio[4] = 0.2;
22 e->timings.ratio[5] = 0.05;
23 e->timings.ratio[6] = 0.055;
24 e->timings.ratio[7] = 0.06;
25 e->timings.ratio[8] = 0.027;
26 e->timings.offset[0] = 0;
27 e->timings.offset[1] = 100;
28 e->timings.offset[2] = 200;
29 e->timings.offset[3] = 300;
30 e->timings.offset[4] = 400;
31 e->timings.offset[5] = 500;
32 e->timings.offset[6] = 600;
33
34 e->calculate_oscillators(e->timings);
35
36 for (int x = 0; x < e->num_x; x++) {
37 for (int y = 0; y < e->num_y; y++) {
38 e->animation.dist = e->distance[x][y];
39 e->animation.angle = 5 * e->polar_theta[x][y] + e->move.noise_angle[5] +
40 e->move.directional[3] * e->move.noise_angle[6] *
41 e->animation.dist / 10;
42 e->animation.scale_x = 0.08;
43 e->animation.scale_y = 0.08;
44 e->animation.scale_z = 0.02;
45 e->animation.offset_y = -e->move.linear[0];
46 e->animation.offset_x = 0;
47 e->animation.offset_z = 0;
48 e->animation.z = e->move.linear[1];
49 float show1 = e->render_value(e->animation);
50
51 e->animation.angle = 6 * e->polar_theta[x][y] + e->move.noise_angle[7] +
52 e->move.directional[5] * e->move.noise_angle[8] *
53 e->animation.dist / 10;
54 e->animation.offset_y = -e->move.linear[1];
55 e->animation.z = e->move.linear[2];
56 float show2 = e->render_value(e->animation);
57
58 e->animation.angle = 6 * e->polar_theta[x][y] + e->move.noise_angle[6] +
59 e->move.directional[6] * e->move.noise_angle[7] *
60 e->animation.dist / 10;
61 e->animation.offset_y = e->move.linear[2];
62 e->animation.z = e->move.linear[0];
63 e->animation.dist = e->distance[x][y] * 0.8;
64 float show3 = e->render_value(e->animation);
65
66 float f = 1;
67
68 e->pixel.red = f * (show1 + show2);
69 e->pixel.green = f * (show1 - show2);
70 e->pixel.blue = f * (show3 - show1);
71
72 e->pixel = e->rgb_sanity_check(e->pixel);
73 e->setPixelColorInternal(x, y, e->pixel);
74 }
75 }
76}
77
78
79// ============================================================================
80// Fixed-Point Implementation of Spiralus2
81// ============================================================================
82
84 auto *e = ctx.mEngine.get();
85 e->get_ready();
86 mState.ensureCache(e);
87 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
88 const fl::u8 *perm = PERLIN_NOISE;
89
90 e->timings.master_speed = 0.0015;
91 e->timings.ratio[0] = 1.5;
92 e->timings.ratio[1] = 2.3;
93 e->timings.ratio[2] = 3;
94 e->timings.ratio[3] = 0.05;
95 e->timings.ratio[4] = 0.2;
96 e->timings.ratio[5] = 0.05;
97 e->timings.ratio[6] = 0.055;
98 e->timings.ratio[7] = 0.06;
99 e->timings.ratio[8] = 0.027;
100 e->timings.offset[0] = 0;
101 e->timings.offset[1] = 100;
102 e->timings.offset[2] = 200;
103 e->timings.offset[3] = 300;
104 e->timings.offset[4] = 400;
105 e->timings.offset[5] = 500;
106 e->timings.offset[6] = 600;
107
108 e->calculate_oscillators(e->timings);
109
110 for (int x = 0; x < e->num_x; x++) {
111 for (int y = 0; y < e->num_y; y++) {
112 e->animation.dist = e->distance[x][y];
113 e->animation.angle = 5 * e->polar_theta[x][y] + e->move.noise_angle[5] +
114 e->move.directional[3] * e->move.noise_angle[6] *
115 e->animation.dist / 10;
116 e->animation.scale_x = 0.08;
117 e->animation.scale_y = 0.08;
118 e->animation.scale_z = 0.02;
119 e->animation.offset_y = -e->move.linear[0];
120 e->animation.offset_x = 0;
121 e->animation.offset_z = 0;
122 e->animation.z = e->move.linear[1];
123 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
124
125 e->animation.angle = 6 * e->polar_theta[x][y] + e->move.noise_angle[7] +
126 e->move.directional[5] * e->move.noise_angle[8] *
127 e->animation.dist / 10;
128 e->animation.offset_y = -e->move.linear[1];
129 e->animation.z = e->move.linear[2];
130 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
131
132 e->animation.angle = 6 * e->polar_theta[x][y] + e->move.noise_angle[6] +
133 e->move.directional[6] * e->move.noise_angle[7] *
134 e->animation.dist / 10;
135 e->animation.offset_y = e->move.linear[2];
136 e->animation.z = e->move.linear[0];
137 e->animation.dist = e->distance[x][y] * 0.8;
138 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
139
140 float f = 1;
141
142 e->pixel.red = f * (show1 + show2);
143 e->pixel.green = f * (show1 - show2);
144 e->pixel.blue = f * (show3 - show1);
145
146 e->pixel = e->rgb_sanity_check(e->pixel);
147 e->setPixelColorInternal(x, y, e->pixel);
148 }
149 }
150}
151
152} // namespace fl
153
FPVizState mState
Definition spiralus2.h:23
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