FastLED 3.10.8
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 216 of file ease.cpp.hpp.

216 {
217 const u32 MAX = 0xFFFF; // 65535
218 const u32 HALF = (MAX + 1) >> 1; // 32768
219 const fl::u64 M2 = (fl::u64)MAX * MAX; // 65535² = 4 294 836 225
220
221 if (x < HALF) {
222 // first half: y = 4·(x/MAX)³ → y_i = 4·x³ / MAX²
223 fl::u64 xi = x;
224 fl::u64 cube = xi * xi * xi; // x³
225 // add M2/2 for rounding
226 fl::u64 num = 4 * cube + (M2 >> 1);
227 return (u16)(num / M2);
228 } else {
229 // second half: y = 1 − ((2·(1−x/MAX))³)/2
230 // → y_i = MAX − (4·(MAX−x)³ / MAX²)
231 fl::u64 d = MAX - x;
232 fl::u64 cube = d * d * d; // (MAX−x)³
233 fl::u64 num = 4 * cube + (M2 >> 1);
234 return (u16)(MAX - (num / M2));
235 }
236}
int x
Definition simple.h:92
fl::u64 u64
Definition s16x16x4.h:221

References FL_NO_EXCEPT, and x.

Referenced by ease16(), and ease16().

+ Here is the caller graph for this function: