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

◆ ring()

void mood_ring::RingCanvas::ring ( float origin,
float radius,
float sigma,
const RGBf & color,
float gain )

Add a band at distance radius (turns, 0..0.5) from origin, on both sides of it at once: an expanding pulse ring.

Definition at line 122 of file ring_canvas.cpp.

123 {
124 const int n = size();
125 if (n <= 0 || gain <= 0.0f || sigma <= 0.0f)
126 return;
127 for (int i = 0; i < n; ++i) {
128 float d = ringDistance(posOf(i), origin) - radius;
129 if (d < 0.0f)
130 d = -d;
131 const float k = falloff(d, sigma);
132 if (k <= 0.0f)
133 continue;
134 pixel(i, color, gain * k);
135 }
136}
float posOf(int i) const
Position of pixel i in turns.
void pixel(int i, const RGBf &color, float gain)
Add to one pixel, index wrapped.
float ringDistance(float a, float b)
Shortest distance between two ring positions, in turns, in [0, 0.5].
float falloff(float distance, float sigma)
Smooth bump: 1 at distance 0, 0 at distance >= sigma.

References mood_ring::falloff(), pixel(), posOf(), mood_ring::ringDistance(), and size().

Referenced by mood_ring::MoodPainter::drawPulses().

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