def draw_border(surf, color=BLACK, thickness=1):
    """Draw a border around surf of given color and width.

    It works by drawing a sequence of rects with thickness
    1, one inside the other.

    Parameters
    ==========
    surf (pygame.Surface instance)
        surface wherein to draw the border
    color (pygame.Color instance or sequence)
        contains integers from 0 to 255 inclusive,
        representing values for red, green and blue channels
        of a color.
    thickness (integer)
        represents the desired width of the border in pixels.

    New proposed solution
    =====================

    The new proposed solution below needs to be tested and
    profiled before replacing the old one. If it is to
    replace the old one, it also needs to be properly
    commented.

    This new solution is used in the draw_border_on_area()
    function. If proven inferior, change to use the
    current solution in this function.

    ###

    rect = surf.get_rect()

    for i in range(0, thickness*2, 2):

        draw_rect(
          surf,
          color,
          rect.inflate(-i, -i),
          1
        )

    ###
    """
    ### retrieve rect for surf
    rect = surf.get_rect()

    ### for each unit in the border width, draw the rect,
    ### then perform additional setups

    for _ in range(thickness):

        ## draw rect
        draw_rect(surf, color, rect, 1)

        ## decrement dimensions by 2 units

        rect.size = tuple(dimension - 2 for dimension in rect.size)

        ## move rect one unit down and to the right
        rect.move_ip(1, 1)
Draw a border around surf of given color and width.

    It works by drawing a sequence of rects with thickness
    1, one inside the other.

    Parameters
    ==========
    surf (pygame.Surface instance)
        surface wherein to draw the border
    color (pygame.Color instance or sequence)
        contains integers from 0 to 255 inclusive,
        representing values for red, green and blue channels
        of a color.
    thickness (integer)
        represents the desired width of the border in pixels.

    New proposed solution
    =====================

    The new proposed solution below needs to be tested and
    profiled before replacing the old one. If it is to
    replace the old one, it also needs to be properly
    commented.

    This new solution is used in the draw_border_on_area()
    function. If proven inferior, change to use the
    current solution in this function.

    ###

    rect = surf.get_rect()

    for i in range(0, thickness*2, 2):

        draw_rect(
          surf,
          color,
          rect.inflate(-i, -i),
          1
        )

    ###
    
nodezator/surfsman/draw.py