getAnimations method

  1. @override
List<CharacterAnimation> getAnimations(
  1. double progress,
  2. int charCount
)
override

Generates per-character flicker using multi-frequency noise.

Implementation

@override
List<CharacterAnimation> getAnimations(double progress, int charCount) {
  if (charCount == 0) return [];

  return List.generate(charCount, (index) {
    final curved = applyCurve(progress);
    final returnT = sin(curved * pi);
    final flickerT = progress * duration.inMicroseconds / 1000000.0;
    final seed = flickerSeed + index;

    final flicker = noise(seed, (flickerT * 10).floor()) > 0.6 ? 1.0 : 0.3;
    final flickerSlow = noise(seed, (flickerT * 3).floor()) > 0.5 ? 1.0 : 0.5;
    final targetOpacity = flicker * flickerSlow;
    final opacity = 1.0 + (targetOpacity - 1.0) * returnT;

    final useFlicker = returnT > 0.001;
    return CharacterAnimation(
      opacity: opacity.clamp(0.0, 1.0),
      blurSigma: useFlicker && targetOpacity > 0.5 ? blurSigma : 0.0,
      color: useFlicker
          ? (targetOpacity > 0.5 ? glowColor : baseColor)
          : null,
    );
  });
}