FastLED 3.9.15
Loading...
Searching...
No Matches

◆ ToBounds() [1/2]

Transform16 fl::Transform16::ToBounds ( alpha16 max_value)
static

Definition at line 44 of file transform.cpp.

44 {
45 Transform16 tx;
46 // Compute a Q16 “scale” so that:
47 // (alpha16 * scale) >> 16 == max_value when alpha16==0xFFFF
48 alpha16 scale16 = 0;
49 if (max_value) {
50 // numerator = max_value * 2^16
51 uint32_t numer = static_cast<uint32_t>(max_value) << 16;
52 // denom = 0xFFFF; use ceil so 0xFFFF→max_value exactly:
53 uint32_t scale32 = numer / 0xFFFF;
54 scale16 = static_cast<alpha16>(scale32);
55 }
56 tx.scale_x = scale16;
57 tx.scale_y = scale16;
58 tx.offset_x = 0;
59 tx.offset_y = 0;
60 tx.rotation = 0;
61 return tx;
62}
LIB8STATIC uint16_t scale16(uint16_t i, fract16 scale)
Scale a 16-bit unsigned value by an 16-bit value, which is treated as the numerator of a fraction who...
Definition scale8.h:546
uint16_t alpha16
Definition transform.h:21
Transform16()=default

References Transform16(), offset_x, offset_y, rotation, scale16(), scale_x, and scale_y.

Referenced by From().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: