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

◆ easeInOutCubic16()

u16 fl::easeInOutCubic16 ( u16 x)

16-bit cubic ease-in/ease-out function Takes an input value 0-65535 and returns an eased value 0-65535

Definition at line 206 of file ease.cpp.

206 {
207 const u32 MAX = 0xFFFF; // 65535
208 const u32 HALF = (MAX + 1) >> 1; // 32768
209 const fl::u64 M2 = (fl::u64)MAX * MAX; // 65535² = 4 294 836 225
210
211 if (x < HALF) {
212 // first half: y = 4·(x/MAX)³ → y_i = 4·x³ / MAX²
213 fl::u64 xi = x;
214 fl::u64 cube = xi * xi * xi; // x³
215 // add M2/2 for rounding
216 fl::u64 num = 4 * cube + (M2 >> 1);
217 return (u16)(num / M2);
218 } else {
219 // second half: y = 1 − ((2·(1−x/MAX))³)/2
220 // → y_i = MAX − (4·(MAX−x)³ / MAX²)
221 fl::u64 d = MAX - x;
222 fl::u64 cube = d * d * d; // (MAX−x)³
223 fl::u64 num = 4 * cube + (M2 >> 1);
224 return (u16)(MAX - (num / M2));
225 }
226}
int x
Definition simple.h:92
#define MAX(a, b)
Definition math_macros.h:37

References MAX, and x.

Referenced by ease16(), and ease16().

+ Here is the caller graph for this function: