transform method
Returns the value of the object at point t
.
The value of t
is nominally a fraction in the range 0.0 to 1.0, though
in practice it may extend outside this range.
See also:
- evaluate, which is a shorthand for applying transform to the value of an Animation.
- Curve.transform, a similar method for easing curves.
Implementation
@override
T transform(double t) {
assert(t >= 0 && t <= 1, 'Invalid time $t');
assert(keyframes.isNotEmpty, 'No keyframes found');
var duration = _computeDuration(t);
var current = Duration.zero;
for (var i = 0; i < keyframes.length; i++) {
final keyframe = keyframes[i];
final next = current + keyframe.duration;
if (duration < next) {
final localT = (duration - current).inMilliseconds /
keyframe.duration.inMilliseconds;
return keyframe.compute(this, i, localT);
}
current = next;
}
return keyframes.last.compute(this, keyframes.length - 1, 1.0);
}