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