FastLED 3.9.15
Loading...
Searching...
No Matches
polar_waves.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.5;
16 e->timings.ratio[0] = 0.0025;
17 e->timings.ratio[1] = 0.0027;
18 e->timings.ratio[2] = 0.0031;
19
20 e->calculate_oscillators(e->timings);
21
22 for (int x = 0; x < e->num_x; x++) {
23 for (int y = 0; y < e->num_y; y++) {
24 e->animation.dist = (e->distance[x][y]);
25 e->animation.angle =
26 e->polar_theta[x][y] - e->animation.dist * 0.1 + e->move.radial[0];
27 e->animation.z = (e->animation.dist * 1.5) - 10 * e->move.linear[0];
28 e->animation.scale_x = 0.15;
29 e->animation.scale_y = 0.15;
30 e->animation.offset_x = e->move.linear[0];
31
32 float show1 = e->render_value(e->animation);
33 e->animation.angle =
34 e->polar_theta[x][y] - e->animation.dist * 0.1 + e->move.radial[1];
35 e->animation.z = (e->animation.dist * 1.5) - 10 * e->move.linear[1];
36 e->animation.offset_x = e->move.linear[1];
37
38 float show2 = e->render_value(e->animation);
39 e->animation.angle =
40 e->polar_theta[x][y] - e->animation.dist * 0.1 + e->move.radial[2];
41 e->animation.z = (e->animation.dist * 1.5) - 10 * e->move.linear[2];
42 e->animation.offset_x = e->move.linear[2];
43
44 float show3 = e->render_value(e->animation);
45
46 float radius = e->radial_filter_radius;
47 float radial = (radius - e->distance[x][y]) / e->distance[x][y];
48
49 e->pixel.red = radial * show1;
50 e->pixel.green = radial * show2;
51 e->pixel.blue = radial * show3;
52
53 e->pixel = e->rgb_sanity_check(e->pixel);
54 e->setPixelColorInternal(x, y, e->pixel);
55 }
56 }
57}
58
59
60// ============================================================================
61// Fixed-Point Implementation of Polar_Waves
62// ============================================================================
63
65 auto *e = ctx.mEngine.get();
66 e->get_ready();
67 mState.ensureCache(e);
68 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
69 const fl::u8 *perm = PERLIN_NOISE;
70
71 e->timings.master_speed = 0.5;
72 e->timings.ratio[0] = 0.0025;
73 e->timings.ratio[1] = 0.0027;
74 e->timings.ratio[2] = 0.0031;
75
76 e->calculate_oscillators(e->timings);
77
78 for (int x = 0; x < e->num_x; x++) {
79 for (int y = 0; y < e->num_y; y++) {
80 e->animation.dist = (e->distance[x][y]);
81 e->animation.angle =
82 e->polar_theta[x][y] - e->animation.dist * 0.1 + e->move.radial[0];
83 e->animation.z = (e->animation.dist * 1.5) - 10 * e->move.linear[0];
84 e->animation.scale_x = 0.15;
85 e->animation.scale_y = 0.15;
86 e->animation.offset_x = e->move.linear[0];
87
88 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
89 e->animation.angle =
90 e->polar_theta[x][y] - e->animation.dist * 0.1 + e->move.radial[1];
91 e->animation.z = (e->animation.dist * 1.5) - 10 * e->move.linear[1];
92 e->animation.offset_x = e->move.linear[1];
93
94 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
95 e->animation.angle =
96 e->polar_theta[x][y] - e->animation.dist * 0.1 + e->move.radial[2];
97 e->animation.z = (e->animation.dist * 1.5) - 10 * e->move.linear[2];
98 e->animation.offset_x = e->move.linear[2];
99
100 float show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
101
102 float radius = e->radial_filter_radius;
103 float radial = (radius - e->distance[x][y]) / e->distance[x][y];
104
105 e->pixel.red = radial * show1;
106 e->pixel.green = radial * show2;
107 e->pixel.blue = radial * show3;
108
109 e->pixel = e->rgb_sanity_check(e->pixel);
110 e->setPixelColorInternal(x, y, e->pixel);
111 }
112 }
113}
114
115} // namespace fl
116
void draw(Context &ctx) override
FPVizState mState
Definition polar_waves.h:22
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