paint method
Draw itself and its children, according to the calculated
box.offset
Implementation
@override
void paint(Context context) {
super.paint(context);
final adjustedValue = value.clamp(0.00001, .99999);
final rx = box!.width / 2;
final ry = box!.height / 2;
const angleStart = math.pi / 2;
final angleEnd = angleStart - math.pi * 2 * adjustedValue;
final startTop = PdfPoint(
box!.left + rx + math.cos(angleStart) * rx,
box!.bottom + ry + math.sin(angleStart) * ry,
);
final endTop = PdfPoint(
box!.left + rx + math.cos(angleEnd) * rx,
box!.bottom + ry + math.sin(angleEnd) * ry,
);
final startBottom = PdfPoint(
box!.left + rx + math.cos(angleStart) * (rx - strokeWidth),
box!.bottom + ry + math.sin(angleStart) * (ry - strokeWidth),
);
final endBottom = PdfPoint(
box!.left + rx + math.cos(angleEnd) * (rx - strokeWidth),
box!.bottom + ry + math.sin(angleEnd) * (ry - strokeWidth),
);
if (backgroundColor != null && value < 1) {
context.canvas
..moveTo(startTop.x, startTop.y)
..bezierArc(
startTop.x,
startTop.y,
rx,
ry,
endTop.x,
endTop.y,
large: adjustedValue < .5,
sweep: true,
)
..lineTo(endBottom.x, endBottom.y)
..bezierArc(
endBottom.x,
endBottom.y,
rx - strokeWidth,
ry - strokeWidth,
startBottom.x,
startBottom.y,
large: adjustedValue < .5,
)
..lineTo(startTop.x, startTop.y)
..setFillColor(backgroundColor)
..fillPath();
}
if (value > 0) {
context.canvas
..moveTo(startTop.x, startTop.y)
..bezierArc(
startTop.x,
startTop.y,
rx,
ry,
endTop.x,
endTop.y,
large: adjustedValue > .5,
)
..lineTo(endBottom.x, endBottom.y)
..bezierArc(
endBottom.x,
endBottom.y,
rx - strokeWidth,
ry - strokeWidth,
startBottom.x,
startBottom.y,
large: adjustedValue > .5,
sweep: true,
)
..lineTo(startTop.x, startTop.y)
..setFillColor(color ?? PdfColors.indigo)
..fillPath();
}
}