paintArm method
Paints the arm given its joint positions.
Implementation
void paintArm(Canvas canvas, Size size, ArmCoordinates coordinates, {double opacity = 1}) {
final points = [
coordinates.shoulder,
coordinates.elbow,
coordinates.wrist,
coordinates.fingers,
];
final lineColors = [
Colors.red,
Colors.green,
Colors.blue,
];
final firstCirclePaint = Paint()
..color = lineColors[0].withOpacity(opacity)
..style = PaintingStyle.fill;
canvas.drawCircle(points[0], screen / 40, firstCirclePaint);
// Draw lines based off joint position
for (var i = 0; i < points.length - 1; i++) {
final paint = Paint()
..color = lineColors[i].withOpacity(opacity)
..strokeWidth = screen / 50;
canvas.drawLine(points[i], points[i + 1], paint);
}
// Draw circles on each joint
for (var i = 0; i < points.length - 1; i++) {
final circlePaint = Paint()
..color = lineColors[i].withOpacity(opacity)
..style = PaintingStyle.fill;
canvas.drawCircle(points[i + 1], screen / 50, circlePaint);
}
}