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

◆ easeInOutCubic8()

u8 fl::easeInOutCubic8 ( u8 i)

8-bit cubic ease-in/ease-out function Takes an input value 0-255 and returns an eased value 0-255 More pronounced easing curve than quadratic

Definition at line 85 of file ease.cpp.hpp.

85 {
86 constexpr u16 MAX = 0xFF; // 255
87 constexpr u16 HALF = (MAX + 1) >> 1; // 128
88 constexpr u32 DENOM = (u32)MAX * MAX; // 255*255 = 65025
89 constexpr u32 ROUND = DENOM >> 1; // for rounding
90
91 if (i < HALF) {
92 // first half: y = 4·(i/MAX)³ → y_i = 4·i³ / MAX²
93 u32 ii = i;
94 u32 cube = ii * ii * ii; // i³
95 u32 num = 4 * cube + ROUND; // 4·i³, +half denom for rounding
96 return u8(num / DENOM);
97 } else {
98 // second half: y = 1 − ((−2·t+2)³)/2
99 // where t = i/MAX; equivalently:
100 // y_i = MAX − (4·(MAX−i)³ / MAX²)
101 u32 d = MAX - i;
102 u32 cube = d * d * d; // (MAX−i)³
103 u32 num = 4 * cube + ROUND;
104 return u8(MAX - (num / DENOM));
105 }
106}
unsigned char u8
Definition stdint.h:131

References FL_NO_EXCEPT.

Referenced by ease8(), and ease8().

+ Here is the caller graph for this function: