connectorEntryPoint function
Implementation
@pragma('vm:prefer-inline')
Offset connectorEntryPoint(Rect rect, Offset anchor) {
final from = rect.center;
final vector = anchor - from;
final vx = vector.dx;
final vy = vector.dy;
if (vx.abs() < 1e-6 && vy.abs() < 1e-6) return rect.center;
double? bestT;
if (vx != 0) {
for (final x in [rect.left, rect.right]) {
final t = (x - from.dx) / vx;
final y = from.dy + t * vy;
if (t > 0 && y >= rect.top - 1e-6 && y <= rect.bottom + 1e-6) {
if (bestT == null || t < bestT) bestT = t;
}
}
}
if (vy != 0) {
for (final y in [rect.top, rect.bottom]) {
final t = (y - from.dy) / vy;
final x = from.dx + t * vx;
if (t > 0 && x >= rect.left - 1e-6 && x <= rect.right + 1e-6) {
if (bestT == null || t < bestT) bestT = t;
}
}
}
return bestT == null ? rect.center : from + vector * bestT;
}