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

◆ easeInOutQuad8()

u8 fl::easeInOutQuad8 ( u8 i)

8-bit quadratic ease-in/ease-out function Takes an input value 0-255 and returns an eased value 0-255 The curve starts slow, accelerates in the middle, then slows down again

Definition at line 55 of file ease.cpp.

55 {
56 constexpr u16 MAX = 0xFF; // 255
57 constexpr u16 HALF = (MAX + 1) >> 1; // 128
58 constexpr u16 DENOM = MAX; // divisor for scaling
59 constexpr u16 ROUND = DENOM >> 1; // for rounding
60
61 if (i < HALF) {
62 // first half: y = 2·(i/MAX)² → y_i = 2·i² / MAX
63 u32 t = i;
64 u32 num = 2 * t * t + ROUND; // 2*i², +half for rounding
65 return u8(num / DENOM);
66 } else {
67 // second half: y = 1 − 2·(1−i/MAX)²
68 // → y_i = MAX − (2·(MAX−i)² / MAX)
69 u32 d = MAX - i;
70 u32 num = 2 * d * d + ROUND; // 2*(MAX−i)², +half for rounding
71 return u8(MAX - (num / DENOM));
72 }
73}
static uint32_t t
Definition Luminova.h:54
#define MAX(a, b)
Definition math_macros.h:37
unsigned char u8
Definition int.h:17

References MAX, and t.

Referenced by ease8(), and ease8().

+ Here is the caller graph for this function: