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 215 of file ease.cpp.hpp.

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

References MAX, and x.

Referenced by ease16(), and ease16().

+ Here is the caller graph for this function: