def combine_surfaces(
    surfaces,
    retrieve_pos_from="midright",
    assign_pos_to="midleft",
    offset_pos_by=(0, 0),
    padding=0,
    background_color=(*BLACK, 0),
):
    """Return new surf from given ones."""
    ### obtain rects from given surfaces
    rects = [surf.get_rect() for surf in surfaces]

    ### define rects manager
    rectsman = RectsManager(rects.__iter__)

    ### position rects

    rectsman.snap_rects_ip(
        retrieve_pos_from=retrieve_pos_from,
        assign_pos_to=assign_pos_to,
        offset_pos_by=offset_pos_by,
    )

    ### get an inflated copy of the rectsman

    inflation_amount = padding * 2

    inflated_rect = rectsman.inflate(inflation_amount, inflation_amount)

    ### position inflated copy in origin and center
    ### the rectsman on it

    inflated_rect.topleft = (0, 0)
    rectsman.center = inflated_rect.center

    ### create new surface and blit surfaces on it

    new_surf = render_rect(*inflated_rect.size, color=background_color)

    for surf, rect in zip(surfaces, rects):
        new_surf.blit(surf, rect)

    ### finally return the surf
    return new_surf
Return new surf from given ones.
nodezator/surfsman/render.py