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

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

References MAX, and t.

Referenced by ease8(), and ease8().

+ Here is the caller graph for this function: