2024-01-01 18:31:10 +01:00
|
|
|
import 'dart:math' as Math;
|
|
|
|
|
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-01 18:31:10 +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-01 18:31:10 +01:00
|
|
|
double radius = Math.pow(((value + 5) * 500 / 100) / 1.5, 1.14).toDouble();
|
2023-12-17 23:00:31 +01:00
|
|
|
canvas.drawCircle(Offset(size.width / 6, size.height / 4), radius, paint);
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
|
|
|
}
|