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

Method VegasVisualizer

examples/LuminescentGrand/shared/Painter.cpp:361–407  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

359}
360
361void Painter::VegasVisualizer(const KeyboardState& keyboard,
362 const int* led_column_table, int led_column_table_length,
363 LedRopeInterface* led_rope) {
364
365 led_rope->RawBeginDraw();
366
367 uint32_t skipped_lights = 0;
368 for (int i = 0; i < led_column_table_length; ++i) {
369 const Key& key = keyboard.mKeys[i];
370 uint32_t painted_lights = 0;
371
372 // % of lights that are active.
373 const float active_lights_factor = led_column_table[i] * fl::sqrt(key.mCurrColor.v_);
374 const float inactive_lights_factor = 1.0f - active_lights_factor;
375 const float taper_point_1 = inactive_lights_factor / 2.0f;
376 const float taper_point_2 = taper_point_1 + active_lights_factor;
377
378 const int taper_idx_1 = static_cast<int>(fl::floor(taper_point_1 * led_column_table[i]));
379 const int taper_idx_2 = static_cast<int>(fl::floor(taper_point_2 * led_column_table[i]));
380
381 const Color3i c = key.mCurrColor.ToRGB();
382
383 for (int i = 0; i < taper_idx_1 / 2; ++i) {
384 led_rope->RawDrawPixel(Color3i::Black());
385 painted_lights++;
386 }
387
388 int length = taper_idx_2 - taper_idx_1;
389 for (int i = 0; i < fl::min(200, length); ++i) {
390 led_rope->RawDrawPixel(c);
391 painted_lights++;
392 }
393
394 length = led_column_table[i] - taper_idx_2;
395 for (int i = 0; i < length; ++i) {
396 led_rope->RawDrawPixel(Color3i::Black());
397 painted_lights++;
398 }
399 skipped_lights += fl::max(0, static_cast<int32_t>(led_column_table[i]) - static_cast<int32_t>(painted_lights));
400 }
401
402 for (uint32_t i = 0; i < skipped_lights; ++i) {
403 led_rope->RawDrawPixel(Color3i::Black());
404 }
405
406 led_rope->RawCommitDraw();
407}
408
409void Painter::PaintBrightSurprise(
410 const KeyboardState& keyboard,

Callers

nothing calls this directly

Calls 7

sqrtFunction · 0.85
floorFunction · 0.85
maxFunction · 0.85
RawBeginDrawMethod · 0.80
RawDrawPixelMethod · 0.80
RawCommitDrawMethod · 0.80
ToRGBMethod · 0.45

Tested by

no test coverage detected