43 lines
1.1 KiB
Dart
43 lines
1.1 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
import 'dart:math' as math;
|
||
|
|
|
||
|
|
class WavePainter extends CustomPainter {
|
||
|
|
final double animation;
|
||
|
|
final Color color;
|
||
|
|
|
||
|
|
WavePainter({required this.animation, required this.color});
|
||
|
|
|
||
|
|
@override
|
||
|
|
void paint(Canvas canvas, Size size) {
|
||
|
|
final paint = Paint()
|
||
|
|
..color = color
|
||
|
|
..strokeWidth = 1.5
|
||
|
|
..style = PaintingStyle.stroke;
|
||
|
|
|
||
|
|
final path = Path();
|
||
|
|
|
||
|
|
// Create simplified wave patterns (reduced from 3 to 2 waves)
|
||
|
|
for (int i = 0; i < 2; i++) {
|
||
|
|
path.reset();
|
||
|
|
final double waveHeight = 15 + (i * 8);
|
||
|
|
final double frequency = 0.015 + (i * 0.008);
|
||
|
|
final double phase = animation + (i * math.pi / 2);
|
||
|
|
|
||
|
|
path.moveTo(0, size.height * 0.4 + (i * 40));
|
||
|
|
|
||
|
|
for (double x = 0; x <= size.width; x += 8) {
|
||
|
|
final y =
|
||
|
|
size.height * 0.4 +
|
||
|
|
(i * 40) +
|
||
|
|
math.sin((x * frequency) + phase) * waveHeight;
|
||
|
|
path.lineTo(x, y);
|
||
|
|
}
|
||
|
|
|
||
|
|
canvas.drawPath(path, paint..color = color.withOpacity(0.2 - (i * 0.05)));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@override
|
||
|
|
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
||
|
|
}
|