paint method
void
paint(
- Canvas canvas,
- Size size,
- WorldToScreen worldToScreen,
- ScreenToWorld screenToWorld,
- double scale,
override
Implementation
@override
void paint(
Canvas canvas,
Size size,
WorldToScreen worldToScreen,
ScreenToWorld screenToWorld,
double scale,
) {
if (vertices.length < 2) return;
final mappedPoints =
vertices.map((v) => worldToScreen(v.$1, v.$2)).toList();
final polygonPath = Path()..moveTo(mappedPoints[0].dx, mappedPoints[0].dy);
for (int i = 1; i < mappedPoints.length; i++) {
polygonPath.lineTo(mappedPoints[i].dx, mappedPoints[i].dy);
}
polygonPath.close();
if (fillColor != null) {
canvas.drawPath(polygonPath, Paint()..color = fillColor!);
}
canvas.drawPath(
polygonPath,
Paint()
..color = strokeColor
..strokeWidth = strokeWidth
..style = PaintingStyle.stroke
..strokeJoin = StrokeJoin.round,
);
}