318 {
319
320
322
323
325
326 return;
327 }
328
330 if (!led_data) return;
331
332 if (use_multi_sampling) {
333
334 for (fl::size led_idx = 0; led_idx <
mNumLeds; ++led_idx) {
335
336 Tile2x2_u8_wrap tile =
at_wrap(
static_cast<float>(led_idx));
337
338
339 fl::u32 r_accum = 0, g_accum = 0, b_accum = 0;
340 fl::u32 total_weight = 0;
341
342
345 const auto& entry = tile.at(
x,
y);
346 vec2<u16>
pos = entry.first;
347 fl::u8 weight = entry.second;
348
349
350 if (
pos.x < source_surface->width() &&
pos.y < source_surface->height()) {
351
352 CRGB sample_color = source_surface->at(
pos.x,
pos.y);
353
354
355 r_accum += static_cast<fl::u32>(sample_color.r) * weight;
356 g_accum += static_cast<fl::u32>(sample_color.g) * weight;
357 b_accum += static_cast<fl::u32>(sample_color.b) * weight;
358 total_weight += weight;
359 }
360 }
361 }
362
363
365 if (total_weight > 0) {
366 final_color.r =
static_cast<fl::u8>(r_accum / total_weight);
367 final_color.g =
static_cast<fl::u8>(g_accum / total_weight);
368 final_color.b =
static_cast<fl::u8>(b_accum / total_weight);
369 }
370
371
372 led_data[led_idx] = final_color;
373 }
374 } else {
375
376 for (fl::size led_idx = 0; led_idx <
mNumLeds; ++led_idx) {
377
379
380
381 vec2i16 coord(
static_cast<fl::i16
>(rect_pos.x + 0.5f),
382 static_cast<fl::i16>(rect_pos.y + 0.5f));
383
384
385 coord.x =
fl::max(0,
fl::min(coord.x,
static_cast<fl::i16
>(source_surface->width()) - 1));
386 coord.y =
fl::max(0,
fl::min(coord.y,
static_cast<fl::i16
>(source_surface->height()) - 1));
387
388
389 CRGB sampled_color = source_surface->at(coord.x, coord.y);
390
391
392 led_data[led_idx] = sampled_color;
393 }
394 }
395}
fl::shared_ptr< fl::Grid< CRGB > > & getOrCreateInputSurface()
PixelStorage mPixelStorage
Tile2x2_u8_wrap at_wrap(float i) const
vec2f at_no_wrap(fl::u16 i) const
FL_DISABLE_WARNING_PUSH U constexpr common_type_t< T, U > min(T a, U b) FL_NOEXCEPT
constexpr common_type_t< T, U > max(T a, U b) FL_NOEXCEPT
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>