ModernMemoires/lib/utils/circle_painter.dart

24 lines
627 B
Dart
Raw Normal View History

2024-01-09 12:34:44 +01:00
import 'dart:math' as math;
2024-01-01 18:31:10 +01:00
2023-12-17 23:00:31 +01:00
import 'package:flutter/material.dart';
class CirclePainter extends CustomPainter {
final double value;
2024-01-01 18:31:10 +01:00
final Color color; // New field for color
2023-12-17 23:00:31 +01:00
2024-01-09 12:34:44 +01:00
CirclePainter(this.value, this.color);
2023-12-17 23:00:31 +01:00
@override
void paint(Canvas canvas, Size size) {
var paint = Paint()
2024-01-01 18:31:10 +01:00
..color = color.withOpacity(0.5) // Use the passed color
2023-12-17 23:00:31 +01:00
..style = PaintingStyle.fill;
2024-01-09 12:34:44 +01:00
double radius = math.pow(((value + 5) * 500 / 100) / 1.5, 1.14).toDouble();
2024-01-13 17:07:11 +01:00
canvas.drawCircle(const Offset(10, 109), radius, paint);
2023-12-17 23:00:31 +01:00
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
}