def increase_surf_border(
    surface: Surface,
    color: {
        'widget_name': 'color_button',
        'widget_kwargs': {'color_format': 'rgb_tuple'},
        'type': (tuple, list, str, Color),
    } = (0, 0, 0),
    thickness: 'positive_integer' = 1,
) -> [
    {'name': 'larger_surface', 'type': Surface},
]:
    """Return new larger surface with added border.

    The generated image has per pixel alphas (it is generated with
    Surface.convert_alpha and made fully transparent before drawing
    the border) so you might want to convert it back afterwards
    with Surface.convert().
    """
    ### create larger surface with added thickness and fully
    ### transparent

    new_size = (
        ## get rect
        surface.get_rect()
        ## inflate it
        .inflate(thickness*2, thickness*2)
        ## grab size
        .size
    )

    larger_surf = Surface(new_size).convert_alpha()
    larger_surf.fill((0, 0, 0, 0)) # make fully transparent

    ### fill only border areas

    rect = larger_surf.get_rect()

    for border_rect in (

        # top border
        (*rect.topleft, rect.width, thickness),

        # bottom border
        (*rect.move(0, -thickness).bottomleft,
        rect.width, thickness),

        # left border
        (*rect.move(0, thickness).topleft,
        thickness, rect.height - (thickness*2)),

        # right border
        (*rect.move(-thickness, thickness).topright,
        thickness, rect.height - (thickness*2)),

    ):
        larger_surf.fill(color, border_rect)

    ### blit original surface on larger one
    larger_surf.blit(surface, (thickness, thickness))

    ### return larger surf
    return larger_surf
Return new larger surface with added border.

    The generated image has per pixel alphas (it is generated with
    Surface.convert_alpha and made fully transparent before drawing
    the border) so you might want to convert it back afterwards
    with Surface.convert().
    
nodezator/graphman/capsulenode/pygamedefs.py