def generate_grid_lines(
    unit_rect,
    area_rect,
    use_vectors=False,
    separate_orientation=False,
):
    """Generate and return a list of grid-like lines.

    The list items are tuples containing two points each,
    representing the start and end points of a line.

    E.g.: [((0, 0), (10, 10)), ((3, 3), (5, 5))...]

    unit_rect
        pygame.Rect instance representing an unit in the
        grid.
    area_rect
        pygame.Rect instance representing the area covered
        by the grid.
    use_vectors
        Boolean indicating whether to convert points from
        tuples instances (default behaviour) to
        pygame.math.Vector2 instances.
    separate_orientation
        Boolean indicating whether to return both horizontal
        and vertical lines as a single list (default
        behaviour) or return them in two different lists.
    """
    unit_width, unit_height = unit_rect.size

    if (area_rect.width < unit_width) or (area_rect.height < unit_height):
        raise ValueError("area_rect mustn't be smaller than unit_rect.")

    ### get rect edges

    top, bottom = area_rect.top, area_rect.bottom
    left, right = area_rect.left, area_rect.right

    ### get value for cross sections in x and y axes

    x_sections = list(range(left, right, unit_width))
    y_sections = list(range(top, bottom, unit_height))

    ### store start and end point pairs for each orientation

    vert_start_points = [(x, top) for x in x_sections]
    vert_end_points = [(x, bottom) for x in x_sections]

    horiz_start_points = [(left, y) for y in y_sections]
    horiz_end_points = [(right, y) for y in y_sections]

    ### if requested, convert points into vectors

    if use_vectors:
        vert_start_points = list(map(Vector2, vert_start_points))
        vert_end_points = list(map(Vector2, vert_end_points))
        horiz_start_points = list(map(Vector2, horiz_start_points))
        horiz_end_points = list(map(Vector2, horiz_end_points))

    ### pair start and end points in each orientation;
    ### the paired points represent straight lines,
    ### so that's how they're called;

    vert_lines = list(zip(vert_start_points, vert_end_points))

    horiz_lines = list(zip(horiz_start_points, horiz_end_points))

    ### if requested, return both horizontal and vertical
    ### lines as they are, separated by orientation
    if separate_orientation:
        return horiz_lines, vert_lines

    ### otherwise, return a concatenated single list
    else:
        return horiz_lines + vert_lines
Generate and return a list of grid-like lines.

    The list items are tuples containing two points each,
    representing the start and end points of a line.

    E.g.: [((0, 0), (10, 10)), ((3, 3), (5, 5))...]

    unit_rect
        pygame.Rect instance representing an unit in the
        grid.
    area_rect
        pygame.Rect instance representing the area covered
        by the grid.
    use_vectors
        Boolean indicating whether to convert points from
        tuples instances (default behaviour) to
        pygame.math.Vector2 instances.
    separate_orientation
        Boolean indicating whether to return both horizontal
        and vertical lines as a single list (default
        behaviour) or return them in two different lists.
    
nodezator/our3rdlibs/grid/main.py