MCPcopy Create free account
hub / github.com/FastLED/FastLED / Paint

Method Paint

examples/LuminescentGrand/shared/Painter.cpp:99–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97
98
99void Painter::Paint(uint32_t now_ms,
100 uint32_t delta_ms,
101 VisState vis_state,
102 KeyboardState* keyboard,
103 LedRopeInterface* light_rope) {
104 for (int i = 0; i < KeyboardState::kNumKeys; ++i) {
105 Key& key = keyboard->mKeys[i];
106
107 const float time_delta_ms = static_cast<float>(now_ms - key.mEventTime);
108
109 const float lum = CalcLuminance(time_delta_ms, keyboard->mSustainPedal, key, i);
110 const float sat = CalcSaturation(time_delta_ms, key.mCurrColor, key.mOn);
111
112 //if (key.mIdx == 56) {
113 // dprint("lum: "); dprint(lum*255.f); dprint(" sat:"); dprintln(sat*255.f);
114 //}
115
116 key.mCurrColor.v_ = lum;
117 key.mCurrColor.s_ = sat;
118
119 // Removing this line breaks one of the visualizers...
120 // TODO: Figure out a cleaner solution.
121 light_rope->Set(i, key.mCurrColor.ToRGB());
122 }
123
124 LedColumns led_columns = LedLayoutArray();
125
126 switch (vis_state) {
127 case Painter::kBlockNote: {
128 light_rope->DrawSequentialRepeat(kNumLightsPerNote);
129 break;
130 }
131 case Painter::kColumnNote: {
132 light_rope->DrawRepeat(led_columns.array, kNumKeys);
133 break;
134 }
135 case Painter::kVUNote: {
136 PaintVuNotes(now_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
137 break;
138 }
139 case Painter::kVUMidNote: {
140 PaintVuMidNotesFade(delta_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
141 break;
142 }
143
144 case Painter::kVegas: { // aka "vegas mode?"
145 VegasVisualizer(*keyboard, led_columns.array, kNumKeys, light_rope);
146 break;
147 }
148
149 case Painter::kBrightSurprise: {
150 PaintBrightSurprise(*keyboard, led_columns.array, kNumKeys, light_rope);
151 break;
152 }
153
154 case Painter::kVUSpaceInvaders: {
155 PaintVuSpaceInvaders(now_ms, *keyboard, led_columns.array, kNumKeys, light_rope);
156 break;

Callers

nothing calls this directly

Calls 7

CalcLuminanceFunction · 0.85
CalcSaturationFunction · 0.85
LedLayoutArrayFunction · 0.85
DrawSequentialRepeatMethod · 0.80
DrawRepeatMethod · 0.80
SetMethod · 0.45
ToRGBMethod · 0.45

Tested by

no test coverage detected