FastLED 3.9.15
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 671 of file lib8tion.h.

672{
673 if( i < 64) {
674 // start with slope 0.5
675 i /= 2;
676 } else if( i > (255 - 64)) {
677 // end with slope 0.5
678 i = 255 - i;
679 i /= 2;
680 i = 255 - i;
681 } else {
682 // in the middle, use slope 192/128 = 1.5
683 i -= 64;
684 i += (i / 2);
685 i += 32;
686 }
687
688 return i;
689}

References LIB8STATIC.