rect.pointNearestToPoint(p)

Return the point on the boundary of the rectangle nearest to the point p.