FastLED 3.9.15
Loading...
Searching...
No Matches
zoom.cpp.hpp
Go to the documentation of this file.
5
8
9namespace fl {
10
11void Zoom::draw(Context &ctx) {
12 auto *e = ctx.mEngine.get();
13 e->get_ready();
14
15 e->run_default_oscillators();
16 e->timings.master_speed = 0.003;
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 = (e->distance[x][y] * e->distance[x][y]) / 2;
22 e->animation.angle = e->polar_theta[x][y];
23
24 e->animation.scale_x = 0.005;
25 e->animation.scale_y = 0.005;
26
27 e->animation.offset_y = -10 * e->move.linear[0];
28 e->animation.offset_x = 0;
29 e->animation.offset_z = 0;
30
31 e->animation.z = 0;
32 e->animation.low_limit = 0;
33 float show1 = e->render_value(e->animation);
34
35 float linear = 1;
36
37 e->pixel.red = show1 * linear;
38 e->pixel.green = 0;
39 e->pixel.blue = 0;
40
41 e->pixel = e->rgb_sanity_check(e->pixel);
42 e->setPixelColorInternal(x, y, e->pixel);
43 }
44 }
45}
46
47
48// ============================================================================
49// Fixed-Point Implementation of Zoom
50// ============================================================================
51
53 auto *e = ctx.mEngine.get();
54 e->get_ready();
55 mState.ensureCache(e);
56 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
57 const fl::u8 *perm = PERLIN_NOISE;
58
59 e->run_default_oscillators();
60 e->timings.master_speed = 0.003;
61 e->calculate_oscillators(e->timings);
62
63 for (int x = 0; x < e->num_x; x++) {
64 for (int y = 0; y < e->num_y; y++) {
65 e->animation.dist = (e->distance[x][y] * e->distance[x][y]) / 2;
66 e->animation.angle = e->polar_theta[x][y];
67
68 e->animation.scale_x = 0.005;
69 e->animation.scale_y = 0.005;
70
71 e->animation.offset_y = -10 * e->move.linear[0];
72 e->animation.offset_x = 0;
73 e->animation.offset_z = 0;
74
75 e->animation.z = 0;
76 e->animation.low_limit = 0;
77 float show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
78
79 float linear = 1;
80
81 e->pixel.red = show1 * linear;
82 e->pixel.green = 0;
83 e->pixel.blue = 0;
84
85 e->pixel = e->rgb_sanity_check(e->pixel);
86 e->setPixelColorInternal(x, y, e->pixel);
87 }
88 }
89}
90
91} // namespace fl
92
void draw(Context &ctx) override
Definition zoom.cpp.hpp:52
FPVizState mState
Definition zoom.h:22
void draw(Context &ctx) override
Definition zoom.cpp.hpp:11
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