applyInterpolation method

  1. @override
void applyInterpolation (
  1. ActorComponent component,
  2. double time,
  3. KeyFrame toFrame,
  4. double mix
)
override

Implementation

@override
void applyInterpolation(
    ActorComponent component, double time, KeyFrame toFrame, double mix) {
  ActorImage imageNode = component as ActorImage;
  Float32List wr = imageNode.animationDeformedVertices;
  Float32List to = (toFrame as KeyFrameImageVertices)._vertices;
  int l = _vertices.length;

  double f = (time - _time) / (toFrame.time - _time);
  if (_interpolator != null) {
    f = _interpolator.getEasedMix(f);
  }

  double fi = 1.0 - f;
  if (mix == 1.0) {
    for (int i = 0; i < l; i++) {
      wr[i] = _vertices[i] * fi + to[i] * f;
    }
  } else {
    double mixi = 1.0 - mix;
    for (int i = 0; i < l; i++) {
      double v = _vertices[i] * fi + to[i] * f;

      wr[i] = wr[i] * mixi + v * mix;
    }
  }

  imageNode.invalidateDrawable();
}