paint method

  1. @override
void paint(
  1. Canvas canvas,
  2. Size size,
  3. double progress,
  4. Offset center,
  5. Color color, {
  6. double radiusMultiplier = 1.0,
  7. Offset positionOffset = Offset.zero,
})
override

Implementation

@override
void paint(
    Canvas canvas, Size size, double progress, Offset center, Color color,
    {double radiusMultiplier = 1.0, Offset positionOffset = Offset.zero}) {
  final adjustedCenter = center + positionOffset;
  final maxRadius =
      math.min(size.width, size.height) * 0.7 * radiusMultiplier;

  // Jumlah pancaran
  final rayCount = 12;
  final rayLength = maxRadius * progress;
  final innerRadius = maxRadius * 0.3 * (1 - progress);

  // Paint untuk ray
  final rayPaint = Paint()
    ..color = color.withOpacity((1 - progress) * 0.9)
    ..strokeWidth = 4.0 * (1 - progress * 0.5) // Lebih tebal di awal
    ..strokeCap = StrokeCap.round
    ..style = PaintingStyle.stroke;

  // Gambar rays dengan gaya kartun (tidak rata)
  for (int i = 0; i < rayCount; i++) {
    final angle = (i * 2 * math.pi / rayCount);
    final zigzag = math.sin(angle * 8) * 5; // Efek zig-zag kartun

    // Titik awal dan akhir ray
    final startX = adjustedCenter.dx + innerRadius * math.cos(angle);
    final startY = adjustedCenter.dy + innerRadius * math.sin(angle);
    final endX = adjustedCenter.dx + (rayLength + zigzag) * math.cos(angle);
    final endY = adjustedCenter.dy + (rayLength + zigzag) * math.sin(angle);

    canvas.drawLine(
      Offset(startX, startY),
      Offset(endX, endY),
      rayPaint,
    );

    // Titik bulat di ujung untuk gaya kartun
    if (progress < 0.7) {
      canvas.drawCircle(
        Offset(endX, endY),
        3.0 * (1 - progress),
        Paint()..color = color.withOpacity((1 - progress) * 0.9),
      );
    }
  }

  // Efek "blink" cepat - lingkaran yang muncul dan menghilang
  if (progress < 0.3) {
    canvas.drawCircle(
      adjustedCenter,
      maxRadius * 0.2 * (1 - progress / 0.3),
      Paint()..color = color.withOpacity(0.7 * (1 - progress / 0.3)),
    );
  }
}