317                                            {
  318    
  319    
  321    
  322    
  324        
  325        return;
  326    }
  327    
  329    if (!led_data) return;
  330    
  331    if (use_multi_sampling) {
  332        
  333        for (fl::size led_idx = 0; led_idx < 
mNumLeds; ++led_idx) {
 
  334            
  335            Tile2x2_u8_wrap tile = 
at_wrap(
static_cast<float>(led_idx));
 
  336            
  337            
  338            fl::u32 r_accum = 0, g_accum = 0, b_accum = 0;
  339            fl::u32 total_weight = 0;
  340 
  341            
  344                    const auto& entry = tile.at(
x, 
y);
 
  345                    vec2<u16> 
pos = entry.first;   
 
  346                    fl::u8 weight = entry.second; 
 
  347                    
  348                    
  349                    if (
pos.x < source_surface->width() && 
pos.y < source_surface->height()) {
 
  350                        
  351                        CRGB sample_color = source_surface->at(
pos.x, 
pos.y);
 
  352                        
  353                        
  354                        r_accum += static_cast<fl::u32>(sample_color.r) * weight;
  355                        g_accum += static_cast<fl::u32>(sample_color.g) * weight;
  356                        b_accum += static_cast<fl::u32>(sample_color.b) * weight;
  357                        total_weight += weight;
  358                    }
  359                }
  360            }
  361            
  362            
  364            if (total_weight > 0) {
  365                final_color.r = 
static_cast<fl::u8>(r_accum / total_weight);
 
  366                final_color.g = 
static_cast<fl::u8>(g_accum / total_weight);
 
  367                final_color.b = 
static_cast<fl::u8>(b_accum / total_weight);
 
  368            }
  369            
  370            
  371            led_data[led_idx] = final_color;
  372        }
  373    } else {
  374        
  375        for (fl::size led_idx = 0; led_idx < 
mNumLeds; ++led_idx) {
 
  376            
  378            
  379            
  380            vec2i16 coord(
static_cast<fl::i16
>(rect_pos.x + 0.5f), 
 
  381                          static_cast<fl::i16>(rect_pos.y + 0.5f));
  382            
  383            
  384            coord.x = 
MAX(0, 
MIN(coord.x, 
static_cast<fl::i16
>(source_surface->width()) - 1));
 
  385            coord.y = 
MAX(0, 
MIN(coord.y, 
static_cast<fl::i16
>(source_surface->height()) - 1));
 
  386            
  387            
  388            CRGB sampled_color = source_surface->at(coord.x, coord.y);
  389            
  390            
  391            led_data[led_idx] = sampled_color;
  392        }
  393    }
  394}
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
@ Black
<div style='background:#000000;width:4em;height:4em;'></div>