396 {
397
399 target_surface->
clear();
400 const u16 width = static_cast<u16>(source_grid.width());
401 const u16 height = static_cast<u16>(source_grid.height());
402
403
404 for (fl::size led_idx = 0; led_idx <
mNumLeds; ++led_idx) {
405
406 Tile2x2_u8_wrap tile =
at_wrap(
static_cast<float>(led_idx));
407
408
409 fl::u32 r_accum = 0, g_accum = 0, b_accum = 0;
410 fl::u32 total_weight = 0;
411
412
415 const auto& entry = tile.at(
x,
y);
416 vec2<u16>
pos = entry.first;
417 fl::u8 weight = entry.second;
418
419
420 if (
pos.x >= 0 &&
pos.x < width &&
421 pos.y >= 0 &&
pos.y < height) {
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->data()[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>