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

Function ColorFromPaletteHDImpl

src/fl/gfx/colorutils.cpp.hpp:305–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

303
304template <fl::u8 PaletteBits, typename Reader>
305CRGB16 ColorFromPaletteHDImpl(const Reader &reader, fl::u16 index,
306 fl::u8x8 brightness,
307 TBlendType blendType) {
308 const fl::u8 frac_bits = 16 - PaletteBits;
309 const fl::u8 palette_last = (fl::u8(1) << PaletteBits) - 1;
310 const fl::u32 segment_size = fl::u32(1) << frac_bits;
311 const fl::u8 entry_index = static_cast<fl::u8>(index >> frac_bits);
312 const fl::u16 frac =
313 static_cast<fl::u16>(index & (segment_size - fl::u32(1)));
314
315 const CRGB rgb1 = reader.read(entry_index);
316 CRGB16 out;
317 if (frac && blendType != NOBLEND) {
318 CRGB rgb2;
319 if (entry_index == palette_last) {
320 rgb2 = blendType == LINEARBLEND_NOWRAP ? rgb1 : reader.read(0);
321 } else {
322 rgb2 = reader.read(entry_index + 1);
323 }
324 out = CRGB16(u8x8::from_raw(lerp_channel_to_hd(
325 rgb1.red, rgb2.red, frac, segment_size)),
326 u8x8::from_raw(lerp_channel_to_hd(
327 rgb1.green, rgb2.green, frac, segment_size)),
328 u8x8::from_raw(lerp_channel_to_hd(
329 rgb1.blue, rgb2.blue, frac, segment_size)));
330 } else {
331 out = promote_rgb_to_hd(rgb1);
332 }
333
334 scale_rgb_hd(out, brightness);
335 return out;
336}
337
338} // namespace
339

Callers

nothing calls this directly

Calls 6

CRGB16Class · 0.85
lerp_channel_to_hdFunction · 0.85
promote_rgb_to_hdFunction · 0.85
scale_rgb_hdFunction · 0.85
u32Enum · 0.50
readMethod · 0.45

Tested by

no test coverage detected