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

◆ applyFancyEffect()

void applyFancyEffect ( uint32_t now,
bool button_active )

Definition at line 132 of file FxWave2d.ino.

132 {
133 uint32_t total = map(fancySpeed.as<uint32_t>(), 0, fancySpeed.max_value(), 1000, 100);
134 static TimeRamp pointTransition = TimeRamp(total, 0, 0);
135
136 if (button_active) {
137 pointTransition.trigger(now, total, 0, 0);
138 }
139
140 if (!pointTransition.isActive(now)) {
141 // no need to draw
142 return;
143 }
144 int mid_x = WIDTH / 2;
145 int mid_y = HEIGHT / 2;
146 // now make a cross
147 int amount = WIDTH / 2;
148 int start_x = mid_x - amount;
149 int end_x = mid_x + amount;
150 int start_y = mid_y - amount;
151 int end_y = mid_y + amount;
152 int curr_alpha = pointTransition.update(now);
153 int left_x = map(curr_alpha, 0, 255, mid_x, start_x);
154 int down_y = map(curr_alpha, 0, 255, mid_y, start_y);
155 int right_x = map(curr_alpha, 0, 255, mid_x, end_x);
156 int up_y = map(curr_alpha, 0, 255, mid_y, end_y);
157
158 float curr_alpha_f = curr_alpha / 255.0f;
159
160 float valuef = (1.0f - curr_alpha_f) * fancyIntensity.value() / 255.0f;
161
162 int span = fancyParticleSpan.value() * WIDTH;
163 for (int x = left_x - span; x < left_x + span; x++) {
164 waveFxLower.addf(x, mid_y, valuef);
165 waveFxUpper.addf(x, mid_y, valuef);
166 }
167
168 for (int x = right_x - span; x < right_x + span; x++) {
169 waveFxLower.addf(x, mid_y, valuef);
170 waveFxUpper.addf(x, mid_y, valuef);
171 }
172
173 for (int y = down_y - span; y < down_y + span; y++) {
174 waveFxLower.addf(mid_x, y, valuef);
175 waveFxUpper.addf(mid_x, y, valuef);
176 }
177
178 for (int y = up_y - span; y < up_y + span; y++) {
179 waveFxLower.addf(mid_x, y, valuef);
180 waveFxUpper.addf(mid_x, y, valuef);
181 }
182}
#define WIDTH
Definition Blur2d.ino:9
#define HEIGHT
Definition Blur2d.ino:10
uint32_t x[NUM_LAYERS]
Definition Fire2023.ino:80
uint32_t y[NUM_LAYERS]
Definition Fire2023.ino:81
WaveFx waveFxLower(xyRect, WaveFx::Args{ .factor=SUPER_SAMPLE_4X,.half_duplex=true,.speed=0.18f,.dampening=9.0f,.crgbMap=WaveCrgbGradientMapPtr::New(electricBlueFirePal), })
UISlider fancyParticleSpan("Fancy Particle Span", 0.06f, 0.01f, 0.2f, 0.01f)
WaveFx waveFxUpper(xyRect, WaveFx::Args{ .factor=SUPER_SAMPLE_4X,.half_duplex=true,.speed=0.25f,.dampening=3.0f,.crgbMap=WaveCrgbGradientMapPtr::New(electricGreenFirePal), })
UISlider fancySpeed("Fancy Speed", 796, 0, 1000, 1)
UISlider fancyIntensity("Fancy Intensity", 32, 1, 255, 1)
uint8_t update(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::update(), 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: