applyInterpolation method
void
applyInterpolation(
- ActorComponent? component,
- double time,
- KeyFrame toFrame,
- double mix,
override
Implementation
@override
void applyInterpolation(
ActorComponent? component, double time, KeyFrame toFrame, double mix) {
GradientColor gradient = component as GradientColor;
Float32List v = (toFrame as KeyFrameGradient)._value;
double f =
_interpolator.getEasedMix((time - _time) / (toFrame.time - _time));
double fi = 1.0 - f;
int ridx = 0;
int wi = 0;
if (mix == 1.0) {
gradient.start[0] = _value[ridx] * fi + v[ridx++] * f;
gradient.start[1] = _value[ridx] * fi + v[ridx++] * f;
gradient.end[0] = _value[ridx] * fi + v[ridx++] * f;
gradient.end[1] = _value[ridx] * fi + v[ridx++] * f;
while (ridx < v.length && wi < gradient.colorStops.length) {
gradient.colorStops[wi++] = _value[ridx] * fi + v[ridx++] * f;
}
} else {
double imix = 1.0 - mix;
// Mix : first interpolate the KeyFrames,
// and then mix on top of the current value.
double val = _value[ridx] * fi + v[ridx] * f;
gradient.start[0] = gradient.start[0] * imix + val * mix;
ridx++;
val = _value[ridx] * fi + v[ridx] * f;
gradient.start[1] = gradient.start[1] * imix + val * mix;
ridx++;
val = _value[ridx] * fi + v[ridx] * f;
gradient.end[0] = gradient.end[0] * imix + val * mix;
ridx++;
val = _value[ridx] * fi + v[ridx] * f;
gradient.end[1] = gradient.end[1] * imix + val * mix;
ridx++;
while (ridx < v.length && wi < gradient.colorStops.length) {
val = _value[ridx] * fi + v[ridx] * f;
gradient.colorStops[wi] = gradient.colorStops[wi] * imix + val * mix;
ridx++;
wi++;
}
}
gradient.markPaintDirty();
}