Code is here if you're interested.
private const int AccelerationRatio = 1; // Start off slowly and speed up private const int DecelerationRatio = 0; private void EasingFade(FadeMode fadeMode, int periodInMilliseconds) { var fadeIn = fadeMode == FadeMode.FadeIn; float progressRatio = fadeIn ? 0 : 1; while (fadeIn ? progressRatio <= 1 : progressRatio >= 0) { _pwnPort.SetDutyCycle(ComputeEasedProgressRatio(AccelerationRatio, DecelerationRatio, progressRatio)); progressRatio = fadeIn ? progressRatio+0.01f : progressRatio-0.01f; // Increment or decrement by 1% Thread.Sleep(periodInMilliseconds / 100); } } private static float ComputeEasedProgressRatio(float accelerationRatio, float decelerationRatio, float progressRatio) { var combinedRatio = accelerationRatio + decelerationRatio; var num = progressRatio; if (combinedRatio == 0.0) return num; var num2 = (float)(2.0 / (2.0 - combinedRatio)); if (num < accelerationRatio) return (float)(((num2 * num) * num) / (2.0 * accelerationRatio)); if (num <= (1.0 - decelerationRatio)) return (float)(num2 * (num - (accelerationRatio / 2.0))); var num5 = (float)(1.0 - num); return (float)(1.0 - (((num2 * num5) * num5) / (2.0 * decelerationRatio))); }