FastLED 3.9.15
Loading...
Searching...
No Matches

◆ draw()

void fl::Water_FP::draw ( Context & ctx)
overridevirtual

Implements fl::IAnimartrix2Viz.

Definition at line 98 of file water.cpp.hpp.

98 {
99 auto *e = ctx.mEngine.get();
100 e->get_ready();
101 mState.ensureCache(e);
102 const fl::i32 *fade_lut = fl::assume_aligned<16>(mState.fade_lut);
103 const fl::u8 *perm = PERLIN_NOISE;
104
105 e->timings.master_speed = 0.037;
106 e->timings.ratio[0] = 0.025;
107 e->timings.ratio[1] = 0.027;
108 e->timings.ratio[2] = 0.031;
109 e->timings.ratio[3] = 0.033;
110 e->timings.ratio[4] = 0.037;
111 e->timings.ratio[5] = 0.1;
112 e->timings.ratio[6] = 0.41;
113
114 e->calculate_oscillators(e->timings);
115
116 for (int x = 0; x < e->num_x; x++) {
117 for (int y = 0; y < e->num_y; y++) {
118
119 e->animation.dist =
120 e->distance[x][y] +
121 4 * fl::sinf(e->move.directional[5] * PI + (float)x / 2) +
122 4 * fl::cosf(e->move.directional[6] * PI + float(y) / 2);
123 e->animation.angle = 1 * e->polar_theta[x][y];
124 e->animation.z = 5;
125 e->animation.scale_x = 0.06;
126 e->animation.scale_y = 0.06;
127 e->animation.offset_z = -10 * e->move.linear[0];
128 e->animation.offset_y = 10;
129 e->animation.offset_x = 10;
130 e->animation.low_limit = 0;
131 e->show1 = render_value_fp_from_float(e->animation, fade_lut, perm);
132
133 e->animation.dist = (10 + e->move.directional[0]) *
134 fl::sinf(-e->move.radial[5] + e->move.radial[0] +
135 (e->distance[x][y] / (3)));
136 e->animation.angle = 1 * e->polar_theta[x][y];
137 e->animation.z = 5;
138 e->animation.scale_x = 0.1;
139 e->animation.scale_y = 0.1;
140 e->animation.offset_z = -10;
141 e->animation.offset_y = 20 * e->move.linear[0];
142 e->animation.offset_x = 10;
143 e->animation.low_limit = 0;
144 e->show2 = render_value_fp_from_float(e->animation, fade_lut, perm);
145
146 e->animation.dist = (10 + e->move.directional[1]) *
147 fl::sinf(-e->move.radial[5] + e->move.radial[1] +
148 (e->distance[x][y] / (3)));
149 e->animation.angle = 1 * e->polar_theta[x][y];
150 e->animation.z = 500;
151 e->animation.scale_x = 0.1;
152 e->animation.scale_y = 0.1;
153 e->animation.offset_z = -10;
154 e->animation.offset_y = 20 * e->move.linear[1];
155 e->animation.offset_x = 10;
156 e->animation.low_limit = 0;
157 e->show3 = render_value_fp_from_float(e->animation, fade_lut, perm);
158
159 e->animation.dist = (10 + e->move.directional[2]) *
160 fl::sinf(-e->move.radial[5] + e->move.radial[2] +
161 (e->distance[x][y] / (3)));
162 e->animation.angle = 1 * e->polar_theta[x][y];
163 e->animation.z = 500;
164 e->animation.scale_x = 0.1;
165 e->animation.scale_y = 0.1;
166 e->animation.offset_z = -10;
167 e->animation.offset_y = 20 * e->move.linear[2];
168 e->animation.offset_x = 10;
169 e->animation.low_limit = 0;
170 e->show4 = render_value_fp_from_float(e->animation, fade_lut, perm);
171
172 e->pixel.blue = (0.7 * e->show2 + 0.6 * e->show3 + 0.5 * e->show4);
173 e->pixel.red = e->pixel.blue - 40;
174 e->pixel.green = 0;
175
176 e->pixel = e->rgb_sanity_check(e->pixel);
177
178 e->setPixelColorInternal(x, y, e->pixel);
179 }
180 }
181}
#define PI
FPVizState mState
Definition water.h:22
unsigned char u8
Definition s16x16x4.h:132
T * assume_aligned(T *ptr) FL_NOEXCEPT
Definition s16x16x4.h:126
float sinf(float value) FL_NOEXCEPT
Definition math.h:352
FASTLED_FORCE_INLINE fl::i32 render_value_fp_from_float(const render_parameters &anim, const fl::i32 *fade_lut, const fl::u8 *perm)
float cosf(float value) FL_NOEXCEPT
Definition math.h:358

References fl::fl::assume_aligned(), fl::cosf(), fl::Context::mEngine, mState, PI, fl::render_value_fp_from_float(), fl::sinf(), fl::x, and fl::y.

+ Here is the call graph for this function: