FastLED 3.10.10
Loading...
Searching...
No Matches

◆ coordToU8< fl::s16x16 >()

template<>
fl::u8 fl::gfx::coordToU8< fl::s16x16 > ( fl::s16x16 alpha)
inline

Definition at line 53 of file primitives.h.

53 {
55 // 1L: the shift must be at least as wide as the result (32768 overflows
56 // a 16-bit int; `1 << 15` is UB on AVR, where int is 16-bit).
57 constexpr fl::s16x16 half = fl::s16x16::from_raw(1L << 15);
58 return (fl::u8)fl::clamp((alpha * c255 + half).to_int(), (fl::i32)0, (fl::i32)255);
59}
static constexpr i32 SCALE
Definition s16x16.h:25
static constexpr FASTLED_FORCE_INLINE s16x16 from_raw(i32 raw) FL_NO_EXCEPT
Definition s16x16.h:56
unsigned char u8
Definition s16x16x4.h:132
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT

References fl::clamp(), fl::FL_NO_EXCEPT, fl::s16x16::from_raw(), and fl::s16x16::SCALE.

+ Here is the call graph for this function: