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

◆ applyFancyEffect()

void applyFancyEffect ( uint32_t now,
bool button_active )

Definition at line 139 of file FxWave2d.ino.

139 {
140 uint32_t total =
141 map(fancySpeed.as<uint32_t>(), 0, fancySpeed.getMax(), 1000, 100);
142 static TimeRamp pointTransition = TimeRamp(total, 0, 0);
143
144 if (button_active) {
145 pointTransition.trigger(now, total, 0, 0);
146 }
147
148 if (!pointTransition.isActive(now)) {
149 // no need to draw
150 return;
151 }
152 int mid_x = WIDTH / 2;
153 int mid_y = HEIGHT / 2;
154 // now make a cross
155 int amount = WIDTH / 2;
156 int start_x = mid_x - amount;
157 int end_x = mid_x + amount;
158 int start_y = mid_y - amount;
159 int end_y = mid_y + amount;
160 int curr_alpha = pointTransition.update8(now);
161 int left_x = map(curr_alpha, 0, 255, mid_x, start_x);
162 int down_y = map(curr_alpha, 0, 255, mid_y, start_y);
163 int right_x = map(curr_alpha, 0, 255, mid_x, end_x);
164 int up_y = map(curr_alpha, 0, 255, mid_y, end_y);
165
166 float curr_alpha_f = curr_alpha / 255.0f;
167
168 float valuef = (1.0f - curr_alpha_f) * fancyIntensity.value() / 255.0f;
169
170 int span = fancyParticleSpan.value() * WIDTH;
171 for (int x = left_x - span; x < left_x + span; x++) {
172 waveFxLower.addf(x, mid_y, valuef);
173 waveFxUpper.addf(x, mid_y, valuef);
174 }
175
176 for (int x = right_x - span; x < right_x + span; x++) {
177 waveFxLower.addf(x, mid_y, valuef);
178 waveFxUpper.addf(x, mid_y, valuef);
179 }
180
181 for (int y = down_y - span; y < down_y + span; y++) {
182 waveFxLower.addf(mid_x, y, valuef);
183 waveFxUpper.addf(mid_x, y, valuef);
184 }
185
186 for (int y = up_y - span; y < up_y + span; y++) {
187 waveFxLower.addf(mid_x, y, valuef);
188 waveFxUpper.addf(mid_x, y, valuef);
189 }
190}
int y
Definition Audio.ino:72
#define WIDTH
Definition Audio.ino:33
int x
Definition Audio.ino:71
#define HEIGHT
Definition Audio.ino:32
UISlider fancyParticleSpan("Fancy Particle Span", 0.06f, 0.01f, 0.2f, 0.01f)
WaveFx waveFxLower(xyRect, CreateArgsLower())
UISlider fancySpeed("Fancy Speed", 796, 0, 1000, 1)
UISlider fancyIntensity("Fancy Intensity", 32, 1, 255, 1)
WaveFx waveFxUpper(xyRect, CreateArgsUpper())
uint8_t update8(uint32_t now) override
Compute current 0–255 output based on how much time has elapsed since trigger().
bool isActive(uint32_t now) const override
void trigger(uint32_t now) override
Call this when you want to (re)start the ramp cycle.
long map(long x, long in_min, long in_max, long out_min, long out_max)

References fancyIntensity, fancyParticleSpan, fancySpeed, HEIGHT, fl::TimeRamp::isActive(), fl::TimeRamp::trigger(), fl::TimeRamp::update8(), waveFxLower, waveFxUpper, WIDTH, x, and y.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: