FastLED 3.9.15
Loading...
Searching...
No Matches
slow_fade.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->run_default_oscillators();
16 e->timings.master_speed = 0.00005;
17 e->calculate_oscillators(e->timings);
18
19 for (int x = 0; x < e->num_x; x++) {
20 for (int y = 0; y < e->num_y; y++) {
21 e->animation.dist =
22 fl::sqrtf(e->distance[x][y]) * 0.7 * (e->move.directional[0] + 1.5);
23 e->animation.angle =
24 e->polar_theta[x][y] - e->move.radial[0] + e->distance[x][y] / 5;
25
26 e->animation.scale_x = 0.11;
27 e->animation.scale_y = 0.11;
28
29 e->animation.offset_y = -50 * e->move.linear[0];
30 e->animation.offset_x = 0;
31 e->animation.offset_z = 0;
32
33 e->animation.z = e->move.linear[0];
34 e->animation.low_limit = -0.1;
35 e->animation.high_limit = 1;
36 float show1 = e->render_value(e->animation);
37
38 e->animation.dist = e->animation.dist * 1.1;
39 e->animation.angle += e->move.noise_angle[0] / 10;
40 float show2 = e->render_value(e->animation);
41
42 e->animation.dist = e->animation.dist * 1.1;
43 e->animation.angle += e->move.noise_angle[1] / 10;
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 * (show1 - show2) / 6;
51 e->pixel.blue = radial * (show1 - show3) / 5;
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 Slow_Fade
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->run_default_oscillators();
72 e->timings.master_speed = 0.00005;
73 e->calculate_oscillators(e->timings);
74
75 for (int x = 0; x < e->num_x; x++) {
76 for (int y = 0; y < e->num_y; y++) {
77 e->animation.dist =
78 fl::sqrtf(e->distance[x][y]) * 0.7 * (e->move.directional[0] + 1.5);
79 e->animation.angle =
80 e->polar_theta[x][y] - e->move.radial[0] + e->distance[x][y] / 5;
81
82 e->animation.scale_x = 0.11;
83 e->animation.scale_y = 0.11;
84
85 e->animation.offset_y = -50 * e->move.linear[0];
86 e->animation.offset_x = 0;
87 e->animation.offset_z = 0;
88
89 e->animation.z = e->move.linear[0];
90 e->animation.low_limit = -0.1;
91 e->animation.high_limit = 1;
92 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
93
94 e->animation.dist = e->animation.dist * 1.1;
95 e->animation.angle += e->move.noise_angle[0] / 10;
96 float show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
97
98 e->animation.dist = e->animation.dist * 1.1;
99 e->animation.angle += e->move.noise_angle[1] / 10;
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 * (show1 - show2) / 6;
107 e->pixel.blue = radial * (show1 - show3) / 5;
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 slow_fade.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
float sqrtf(float value) FL_NOEXCEPT
Definition math.h:453
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