397 {
398
400 target_surface->clear();
401 const u16
width =
static_cast<u16
>(source_grid.width());
402 const u16
height =
static_cast<u16
>(source_grid.height());
403
404
405 for (fl::size led_idx = 0; led_idx <
mNumLeds; ++led_idx) {
406
407 Tile2x2_u8_wrap tile =
at_wrap(
static_cast<float>(led_idx));
408
409
410 fl::u32 r_accum = 0, g_accum = 0, b_accum = 0;
411 fl::u32 total_weight = 0;
412
413
416 const auto& entry = tile.at(
x,
y);
417 vec2<u16>
pos = entry.first;
418 fl::u8 weight = entry.second;
419
420
422
423
424 CRGB sample_color = source_grid.at(
pos.x,
pos.y);
425
426
427 r_accum += static_cast<fl::u32>(sample_color.r) * weight;
428 g_accum += static_cast<fl::u32>(sample_color.g) * weight;
429 b_accum += static_cast<fl::u32>(sample_color.b) * weight;
430 total_weight += weight;
431 }
432 }
433 }
434
435
437 if (total_weight > 0) {
438 final_color.r =
static_cast<fl::u8>(r_accum / total_weight);
439 final_color.g =
static_cast<fl::u8>(g_accum / total_weight);
440 final_color.b =
static_cast<fl::u8>(b_accum / total_weight);
441 }
442
443
445 if (led_idx < target_surface->
size()) {
446 target_surface->span()[led_idx] = final_color;
447 }
448 }
449}
fl::shared_ptr< fl::Grid< CRGB > > & getOrCreateInputSurface()
Corkscrew(float totalTurns, fl::u16 numLeds, bool invert=false, const Gap &gapParams=Gap())
Tile2x2_u8_wrap at_wrap(float i) const
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>