FastLED 3.10.8
Loading...
Searching...
No Matches

◆ coordToU8()

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

sqrt is provided by fl::sqrt overloads in math.h for:

  • All floating-point types (float, double)
  • All fixed-point types (s8x8, s12x4, s16x16, s24x8, u8x8, u12x4, u16x16, u24x8)
  • Integer types (via cast to float) Using: using fl::sqrt; (in drawStrokeLine template to find overloads via ADL) Convert a normalized [0,1] Coord value to u8 (0-255) for nscale8. Uses integer arithmetic for fixed-point types; float for float/double. Generic: for fixed-point types (those with .to_int())

Definition at line 26 of file primitives.h.

26 {
27 return (fl::u8)fl::clamp((alpha * T(255.0f) + T(0.5f)).to_int(), 0, 255);
28}
unsigned char u8
Definition stdint.h:131
constexpr enable_if< is_fixed_point< T >::value, T >::type clamp(T x, T lo, T hi) FL_NO_EXCEPT

References fl::clamp(), and fl::FL_NO_EXCEPT.

+ Here is the call graph for this function: