ease function

double ease(
  1. double startValue,
  2. double endValue,
  3. double startTime,
  4. double endTime,
  5. double currentTime,
  6. double initialVelocity,
)

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);
}