apply method

  1. @override
void apply(
  1. double progress
)
override

Apply the given progress level to the effect's target.

Here progress is a variable that is typically in the range from 0 to 1, with 0 being the initial state, and 1 the final state of the effect. See EffectController for details.

This is a main method that MUST be implemented in every derived class.

Implementation

@override
void apply(double progress) {
  final distance = progress * _pathLength;
  final tangent = _pathMetric.getTangentForOffset(distance)!;
  final offset = tangent.position;
  target.position.x += offset.dx - _lastOffset.x;
  target.position.y += offset.dy - _lastOffset.y;
  _lastOffset.x = offset.dx;
  _lastOffset.y = offset.dy;
  if (_followDirection) {
    (target as AngleProvider).angle += -tangent.angle - _lastAngle;
    _lastAngle = -tangent.angle;
  }
}