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

Method PaintVuSpaceInvaders

examples/LuminescentGrand/shared/Painter.cpp:450–486  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450void Painter::PaintVuSpaceInvaders(uint32_t /*now_ms*/,
451 const KeyboardState& keyboard,
452 const int* led_column_table, int led_column_table_length,
453 LedRopeInterface* led_rope) {
454 led_rope->RawBeginDraw();
455
456 Color3i black = Color3i::Black();
457
458 for (int i = 0; i < led_column_table_length; ++i) {
459 const Key& key = keyboard.mKeys[i];
460
461 const int pixel_count = led_column_table[i];
462 const int draw_pixel_count = fl::ceil(pixel_count * fl::sqrt(key.mCurrColor.v_));
463
464 const int black_pixel_count = pixel_count - draw_pixel_count;
465
466 // If i is even
467 if (i % 2 == 0) {
468 for (int j = 0; j < black_pixel_count; ++j) {
469 led_rope->RawDrawPixel(*led_rope->GetIterator(i));
470 }
471 for (int j = 0; j < draw_pixel_count; ++j) {
472 led_rope->RawDrawPixel(black);
473 }
474 } else {
475
476 for (int j = 0; j < draw_pixel_count; ++j) {
477 led_rope->RawDrawPixel(black);
478 }
479
480 for (int j = 0; j < black_pixel_count; ++j) {
481 led_rope->RawDrawPixel(*led_rope->GetIterator(i));
482 }
483 }
484 }
485 led_rope->RawCommitDraw();
486}

Callers

nothing calls this directly

Calls 6

ceilFunction · 0.85
sqrtFunction · 0.85
RawBeginDrawMethod · 0.80
RawDrawPixelMethod · 0.80
RawCommitDrawMethod · 0.80
GetIteratorMethod · 0.45

Tested by

no test coverage detected