FastLED 3.9.15
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages

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

654{
655 if( i < 64) {
656 // start with slope 0.5
657 i /= 2;
658 } else if( i > (255 - 64)) {
659 // end with slope 0.5
660 i = 255 - i;
661 i /= 2;
662 i = 255 - i;
663 } else {
664 // in the middle, use slope 192/128 = 1.5
665 i -= 64;
666 i += (i / 2);
667 i += 32;
668 }
669
670 return i;
671}

References LIB8STATIC.