paint method
Draw itself and its children, according to the calculated
box.offset
Implementation
@override
void paint(Context context) {
super.paint(context);
// Make sure there are enough points to draw anything
if (points.length < 3) {
return;
}
final canvas = context.canvas;
canvas.saveContext();
if (fillColor != null) {
canvas.setFillColor(fillColor!);
}
if (strokeColor != null) {
canvas.setStrokeColor(strokeColor);
}
canvas.setLineWidth(strokeWidth);
// Flip the points on the Y axis.
final flippedPoints =
points.map((e) => PdfPoint(e.x, box!.height - e.y)).toList();
canvas.moveTo(flippedPoints[0].x, flippedPoints[0].y);
for (var i = 0; i < flippedPoints.length; i++) {
canvas.lineTo(flippedPoints[i].x, flippedPoints[i].y);
}
if (close) {
canvas.closePath();
}
if (strokeColor != null && fillColor != null) {
canvas.fillAndStrokePath();
} else if (strokeColor != null) {
canvas.strokePath();
} else {
canvas.fillPath();
}
canvas.restoreContext();
}