FastLED 3.10.6
Loading...
Searching...
No Matches

◆ ease8InOutApprox()

LIB8STATIC fract8 ease8InOutApprox ( fract8 i)

Fast, rough 8-bit ease-in/ease-out function.

Shaped approximately like ease8InOutCubic(), it's never off by more than a couple of percent from the actual cubic S-curve, and it executes more than twice as fast. Use when the cycles are more important than visual smoothness. Asm version takes around 7 cycles on AVR.

Definition at line 602 of file lib8tion.h.

603{
604 if( i < 64) {
605 // start with slope 0.5
606 i /= 2;
607 } else if( i > (255 - 64)) {
608 // end with slope 0.5
609 i = 255 - i;
610 i /= 2;
611 i = 255 - i;
612 } else {
613 // in the middle, use slope 192/128 = 1.5
614 i -= 64;
615 i += (i / 2);
616 i += 32;
617 }
618
619 return i;
620}

References LIB8STATIC.