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

◆ drawGrains()

void mood_ring::FlowLayer::drawGrains ( const MoodPalette & pal,
float dtSec,
RingCanvas & c )
private

Definition at line 105 of file layers.cpp.

105 {
106 const RGBf tint = paletteColor(pal, 1.0f);
107 for (int g = 0; g < kMaxGrains; ++g) {
108 Grain &grain = mGrains[g];
109 if (!grain.active)
110 continue;
111 grain.ageSec += dtSec;
112 if (grain.ageSec >= kGrainLifeSec) {
113 grain.active = false;
114 continue;
115 }
116 const float e = grainEnvelope(grain.ageSec);
117 // A bright core with dimmer shoulders so a grain is a glint, not a
118 // single hot pixel.
119 c.pixel(grain.index, rgbfWhite(), 0.45f * e);
120 c.pixel(grain.index, tint, 0.35f * e);
121 c.pixel(grain.index - 1, tint, 0.20f * e);
122 c.pixel(grain.index + 1, tint, 0.20f * e);
123 }
124}
Grain mGrains[kMaxGrains]
Definition layers.h:61
static const int kMaxGrains
Definition layers.h:50
InputGamut g
Definition rgbw.h:124
float grainEnvelope(float ageSec)
Rise over attack, hold, fall to zero at life. Smooth at both ends.
Definition layers.cpp:48
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.

References mood_ring::FlowLayer::Grain::active, mood_ring::FlowLayer::Grain::ageSec, mood_ring::FlowLayer::Grain::index, kMaxGrains, mGrains, mood_ring::paletteColor(), mood_ring::RingCanvas::pixel(), and mood_ring::rgbfWhite().

Referenced by render().

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