def estimate_clipping_rect(projector, size):
    """
    Return:
    rect -- NSRect style 2d-tuple.
    flipped (bool) -- Whether y-axis is flipped.
    """
    # lt -> rt -> lb -> rb
    image_corners = [(0, 0), (size[0], 0), (0, size[1]), size]
    x_points = []
    y_points = []
    for corner in image_corners:
        x, y = map(int, projector.project_point(*corner))
        x_points.append(x)
        y_points.append(y)
    min_x = min(x_points)
    min_y = min(y_points)
    max_x = max(x_points)
    max_y = max(y_points)

    rect = ((min_x, min_y), (max_x - min_x, max_y - min_y))
    flipped = y_points[3] < 0

    return rect, flipped