def draw_checker_pattern(
    surf, color_a=WHITE, color_b=BLACK, rect_width=10, rect_height=10
):
    """Draw checker pattern on given surf.

    Parameters
    ==========
    surf (pygame.Surface instance)
        surface wherein to draw the checker pattern.
    color_a, color_b (sequence with 3 integers)
        colors to be used in the checker pattern;
        integers are such that 0 <= integer <= 255 and
        together they represent the values of the red,
        green and blue channels of a color;
    rect_width, rect_height (positive integers)
        represent the dimensions of the rect used to
        draw each rect of the checker pattern.
    """
    ### retrieve a rect from the surf
    surf_rect = surf.get_rect()

    ### create a color cycler from the received colors
    next_color = cycle((color_a, color_b)).__next__

    ### create a rect with the provided dimensions, called
    ### unit rect, since it represents an unit or tile in
    ### the checker pattern
    unit_rect = Rect(0, 0, rect_width, rect_height)

    ### use the unit rect width and height as offset
    ### amounts in the x and y axes

    x_offset = rect_width
    y_offset = rect_height

    ### "walk" the surface while blitting the checker
    ### pattern until the surface the entire area of
    ### the surface is covered by the checker pattern

    while True:

        ## if the unit rect isn't touching the
        ## surface area, invert the x_offset,
        ## move it back using such new x_offset and
        ## move it down using the y_offset

        if not surf_rect.colliderect(unit_rect):

            x_offset = -x_offset
            unit_rect.move_ip(x_offset, y_offset)

        ## if even after the previous "if block" the
        ## unit rect still doesn't touch the surface
        ## area, break out of the while loop
        if not surf_rect.colliderect(unit_rect):
            break

        ## otherwise draw the unit rect...
        draw_rect(surf, next_color(), unit_rect)

        ## and move it in the x axis using the x_offset
        unit_rect.move_ip(x_offset, 0)
Draw checker pattern on given surf.

    Parameters
    ==========
    surf (pygame.Surface instance)
        surface wherein to draw the checker pattern.
    color_a, color_b (sequence with 3 integers)
        colors to be used in the checker pattern;
        integers are such that 0 <= integer <= 255 and
        together they represent the values of the red,
        green and blue channels of a color;
    rect_width, rect_height (positive integers)
        represent the dimensions of the rect used to
        draw each rect of the checker pattern.
    
nodezator/surfsman/draw.py