from_lifetime function
Implementation
void from_lifetime(Particle p) {
if (p.lifetime == null) return;
final t = p.lifetimeProgress;
final colorCurveT = p.colorCurve.transform(t);
final gradient = p.colorGradient;
if (gradient != null && gradient.length >= 2) {
p.updateCurrentColor = _lerpGradient(gradient, colorCurveT);
} else if (p.endColor != null) {
p.updateCurrentColor = Color.lerp(p.color, p.endColor!, colorCurveT)!;
}
if (p.endScale != null) {
final st = p.scaleCurve.transform(t);
p.updateCurrentScale = p.startScale + (p.endScale! - p.startScale) * st;
}
if (p.endOpacity != null) {
final ot = p.opacityCurve.transform(t);
if (p.startOpacity == 0.0 && p.endOpacity == 0.0) {
p.updateCurrentOpacity =
(ot <= 0.5 ? ot * 2.0 : (1.0 - ot) * 2.0).clamp(0.0, 1.0);
} else {
p.updateCurrentOpacity =
(p.startOpacity + (p.endOpacity! - p.startOpacity) * ot)
.clamp(0.0, 1.0);
}
}
}