holdBurstPieces function

List<HoldBurstPiece> holdBurstPieces(
  1. Rect head,
  2. double t
)

Os losangos da explosão de uma cabeça head no instante t (0 a 1 da animação). Separado do pintor para ser testado sem pintar: em 0 os oito estão no centro da cabeça, e em 1 a opacidade é zero.

Implementation

List<HoldBurstPiece> holdBurstPieces(Rect head, double t) {
  final progress = t.clamp(0.0, 1.0);
  final distance = progress * _travelHeads * head.width;
  final halfDiagonal = _diagonalHeads * head.width / 2;
  return [
    for (var k = 0; k < kHoldBurstCount; k++)
      HoldBurstPiece(
        center:
            head.center +
            Offset(
                  math.cos(2 * math.pi * k / kHoldBurstCount),
                  math.sin(2 * math.pi * k / kHoldBurstCount),
                ) *
                distance,
        halfDiagonal: halfDiagonal,
        alpha: 1 - progress,
      ),
  ];
}