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

65 {
66 constexpr u16 MAX = 0xFF; // 255
67 constexpr u16 HALF = (MAX + 1) >> 1; // 128
68 constexpr u16 DENOM = MAX; // divisor for scaling
69 constexpr u16 ROUND = DENOM >> 1; // for rounding
70
71 if (i < HALF) {
72 // first half: y = 2·(i/MAX)² → y_i = 2·i² / MAX
73 u32 t = i;
74 u32 num = 2 * t * t + ROUND; // 2*i², +half for rounding
75 return u8(num / DENOM);
76 } else {
77 // second half: y = 1 − 2·(1−i/MAX)²
78 // → y_i = MAX − (2·(MAX−i)² / MAX)
79 u32 d = MAX - i;
80 u32 num = 2 * d * d + ROUND; // 2*(MAX−i)², +half for rounding
81 return u8(MAX - (num / DENOM));
82 }
83}
unsigned char u8
Definition stdint.h:131

References FL_NO_EXCEPT, and t.

Referenced by ease8(), and ease8().

+ Here is the caller graph for this function: