def METHOD_NAME(points, distance, max_shape):
    x1 = np.expand_dims(points[:, 0] - distance[:, 0], -1).clip(0, max_shape[1])
    y1 = np.expand_dims(points[:, 1] - distance[:, 1], -1).clip(0, max_shape[0])
    x2 = np.expand_dims(points[:, 0] + distance[:, 2], -1).clip(0, max_shape[1])
    y2 = np.expand_dims(points[:, 1] + distance[:, 3], -1).clip(0, max_shape[0])
    return np.concatenate((x1, y1, x2, y2), axis=-1)