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 533 of file lib8tion.h.

534{
535 if( i < 64) {
536 // start with slope 0.5
537 i /= 2;
538 } else if( i > (255 - 64)) {
539 // end with slope 0.5
540 i = 255 - i;
541 i /= 2;
542 i = 255 - i;
543 } else {
544 // in the middle, use slope 192/128 = 1.5
545 i -= 64;
546 i += (i / 2);
547 i += 32;
548 }
549
550 return i;
551}

References LIB8STATIC.