code: public static Point closestInteriorPoint (IRectangle r, IPoint p, Point out) {
          out.set(MathUtil.clamp(p.x(), r.minX(), r.maxX()),
                  MathUtil.clamp(p.y(), r.minY(), r.maxY()));
          return out;
      }
docs: Computes the point inside the bounds of the rectangle that's closest to the given point,
  writing the result into {@code out}.
  @return {@code out} for call chaining convenience.