ease function
Implementation
double ease(
double startValue,
double endValue,
double startTime,
double endTime,
double currentTime,
double initialVelocity,
) {
if (startTime == double.negativeInfinity) {
return endValue;
}
if (startValue == endValue) {
return startValue;
}
double normalizedTime = (currentTime - startTime) / (endTime - startTime);
double normalizedVelocity =
initialVelocity / (endValue - startValue) * (endTime - startTime);
double normalizedOutput = normalizedVelocity > 2
? linearAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity)
: constantAccelerationEaseInOutWithInitialVelocity(
normalizedTime, normalizedVelocity);
return startValue + normalizedOutput * (endValue - startValue);
}