getRelativeOffset method

Offset getRelativeOffset(
  1. Size size,
  2. Offset absolute
)

Converts an absolute offset within this widget to a relative offset about the shoulder joint.

Implementation

Offset getRelativeOffset(Size size, Offset absolute) {
  final length = min(size.width / 4, size.height / 2);
  final radius = length * totalArmLength;
  final x = (absolute.dx - size.width / 2 - gripperLength) / radius;
  final y = (size.height - absolute.dy) / radius;
  return Offset(x, y);
}