FastLED 3.10.6
Loading...
Searching...
No Matches

◆ drawPulses()

void mood_ring::MoodPainter::drawPulses ( const MoodPalette & pal,
fl::u32 nowMs )
private

Definition at line 171 of file mood_painter.cpp.

171 {
172 RingCanvas c(mMix);
173 const float origin = wrapTurns(tuning.pulseOrigin);
174 for (int i = 0; i < kMaxPulses; ++i) {
175 Pulse &p = mPulses[i];
176 if (!p.active)
177 continue;
178 const fl::u32 elapsed = nowMs - p.startMs;
179 if (elapsed >= kPulseLifetimeMs) {
180 p.active = false;
181 continue;
182 }
183 const float life =
184 static_cast<float>(elapsed) / static_cast<float>(kPulseLifetimeMs);
185 const float radius = life * 0.5f; // origin to the far side
186 const float sigma = p.downbeat ? kPulseSigmaDownbeat : kPulseSigmaBeat;
187 // Fade in over the first few percent so the ring grows out of the
188 // origin rather than appearing there, then dissolve as it travels.
189 const float amp =
190 p.strength * smoothstepf(0.0f, kPulseFadeIn, life) * (1.0f - life);
191 // Downbeats take the warm end of the family; beats stay white so the
192 // bar boundary is distinguishable by colour as well as by width.
193 const RGBf tint = p.downbeat ? paletteColor(pal, 1.0f) : rgbfWhite();
194 c.ring(origin, radius, sigma, tint, amp);
195 }
196}
Pulse mPulses[kMaxPulses]
static const int kMaxPulses
fl::vector< RGBf > mMix
this frame, summed
float smoothstepf(float e0, float e1, float x)
0 below e0, 1 above e1, smooth in between.
RGBf rgbfWhite()
Definition ring_canvas.h:36
RGBf paletteColor(const MoodPalette &p, float t)
Colour at position t in [0, 1] along the family, at value v.
float wrapTurns(float t)
Wrap into [0, 1).

References mood_ring::MoodPainter::Pulse::active, mood_ring::MoodPainter::Pulse::downbeat, kMaxPulses, mMix, mPulses, mood_ring::paletteColor(), mood_ring::rgbfWhite(), mood_ring::RingCanvas::ring(), mood_ring::smoothstepf(), mood_ring::MoodPainter::Pulse::startMs, mood_ring::MoodPainter::Pulse::strength, tuning, and mood_ring::wrapTurns().

Referenced by draw().

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