warp method

AnimationAction warp(
  1. num startTimeScale,
  2. num endTimeScale,
  3. num duration
)

Changes the playback speed, within the passed time interval, by modifying timeScale gradually from startTimeScale to endTimeScale.

This method can be chained.

Implementation

AnimationAction warp(num startTimeScale, num endTimeScale, num duration) {
  final mixer = this.mixer, now = mixer.time, timeScale = this.timeScale;

  Interpolant? interpolant = _timeScaleInterpolant;

  if (interpolant == null) {
    interpolant = mixer.lendControlInterpolant();
    _timeScaleInterpolant = interpolant;
  }

  final List<num> times = interpolant.parameterPositions;
  final List<num> values = interpolant.sampleValues;

  times[0] = now;
  times[1] = now + duration;

  values[0] = startTimeScale / timeScale;
  values[1] = endTimeScale / timeScale;

  return this;
}