Returns a generator that produces the (x, y) points of a regular polygon.
    `x` and `y` mark the center of the polygon, `radius` indicates the size,
    `sides` specifies what kind of polygon it is.

    Odd-sided polygons have a pointed corner at the top and flat horizontal
    side at the bottom. The `rotationDegrees` argument will rotate the polygon
    counterclockwise.

    The polygon can be stretched by passing `stretchHorizontal` or `stretchVertical`
    arguments. Passing `2.0` for `stretchHorizontal`, for example, will double with
    width of the polygon.

    If `filled` is set to `True`, the generator will also produce the interior
    (x, y) points.

    (Note: The `thickness` parameter is not yet implemented.)

    >>> list(polygon(10, 10, 8, 5))
    [(9, 3), (8, 4), (7, 5), (6, 6), (5, 6), (4, 7), (3, 8), (3, 9), (4, 10), (4, 11), (4, 12), (5, 13), (5, 14), (6, 15), (6, 16), (7, 16), (8, 16), (9, 16), (10, 16), (11, 16), (12, 16), (13, 16), (14, 16), (14, 15), (15, 14), (15, 13), (16, 12), (16, 11), (16, 10), (17, 9), (17, 8), (16, 7), (15, 6), (14, 5), (13, 4), (12, 4), (11, 3), (10, 2)]
    >>> drawPoints(polygon(10, 10, 8, 5))
    ,,,,,,,O,,,,,,,
    ,,,,,,O,O,,,,,,
    ,,,,,O,,,OO,,,,
    ,,,,O,,,,,,O,,,
    ,,OO,,,,,,,,O,,
    ,O,,,,,,,,,,,O,
    O,,,,,,,,,,,,,O
    O,,,,,,,,,,,,,O
    ,O,,,,,,,,,,,O,
    ,O,,,,,,,,,,,O,
    ,O,,,,,,,,,,,O,
    ,,O,,,,,,,,,O,,
    ,,O,,,,,,,,,O,,
    ,,,O,,,,,,,O,,,
    ,,,OOOOOOOOO,,,
    >>> drawPoints(polygon(10, 10, 8, 5, rotationDegrees=20))
    ,,,,,OO,,,,,,,
    ,,,,O,,OOO,,,,
    ,,,,O,,,,,OO,,
    ,,,O,,,,,,,,OO
    ,,O,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    O,,,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    ,,O,,,,,,,,,,O
    ,,,O,,,,,,,,OO
    ,,,,O,,,,,OO,,
    ,,,,O,,OOO,,,,
    ,,,,,OO,,,,,,,

def polygon(x, y, radius, sides, rotationDegrees=0, stretchHorizontal=1.0, stretchVertical=1.0, filled=False, thickness=1):
    """
    Returns a generator that produces the (x, y) points of a regular polygon.
    `x` and `y` mark the center of the polygon, `radius` indicates the size,
    `sides` specifies what kind of polygon it is.

    Odd-sided polygons have a pointed corner at the top and flat horizontal
    side at the bottom. The `rotationDegrees` argument will rotate the polygon
    counterclockwise.

    The polygon can be stretched by passing `stretchHorizontal` or `stretchVertical`
    arguments. Passing `2.0` for `stretchHorizontal`, for example, will double with
    width of the polygon.

    If `filled` is set to `True`, the generator will also produce the interior
    (x, y) points.

    (Note: The `thickness` parameter is not yet implemented.)

    >>> list(polygon(10, 10, 8, 5))
    [(9, 3), (8, 4), (7, 5), (6, 6), (5, 6), (4, 7), (3, 8), (3, 9), (4, 10), (4, 11), (4, 12), (5, 13), (5, 14), (6, 15), (6, 16), (7, 16), (8, 16), (9, 16), (10, 16), (11, 16), (12, 16), (13, 16), (14, 16), (14, 15), (15, 14), (15, 13), (16, 12), (16, 11), (16, 10), (17, 9), (17, 8), (16, 7), (15, 6), (14, 5), (13, 4), (12, 4), (11, 3), (10, 2)]
    >>> drawPoints(polygon(10, 10, 8, 5))
    ,,,,,,,O,,,,,,,
    ,,,,,,O,O,,,,,,
    ,,,,,O,,,OO,,,,
    ,,,,O,,,,,,O,,,
    ,,OO,,,,,,,,O,,
    ,O,,,,,,,,,,,O,
    O,,,,,,,,,,,,,O
    O,,,,,,,,,,,,,O
    ,O,,,,,,,,,,,O,
    ,O,,,,,,,,,,,O,
    ,O,,,,,,,,,,,O,
    ,,O,,,,,,,,,O,,
    ,,O,,,,,,,,,O,,
    ,,,O,,,,,,,O,,,
    ,,,OOOOOOOOO,,,
    >>> drawPoints(polygon(10, 10, 8, 5, rotationDegrees=20))
    ,,,,,OO,,,,,,,
    ,,,,O,,OOO,,,,
    ,,,,O,,,,,OO,,
    ,,,O,,,,,,,,OO
    ,,O,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    O,,,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    ,O,,,,,,,,,,,O
    ,,O,,,,,,,,,,O
    ,,,O,,,,,,,,OO
    ,,,,O,,,,,OO,,
    ,,,,O,,OOO,,,,
    ,,,,,OO,,,,,,,
    """
    if thickness != 1:
        raise NotImplementedError('The pybresenham module is under development and the filled, thickness, and endcap parameters are not implemented. You can contribute at https://github.com/asweigart/pybresenham')

    # Validate sides (x, y, radius, and rotationDegrees are validated in polygonVertices())
    _checkForIntOrFloat(sides)
    if sides < 3:
        raise PyBresenhamException('sides argument must be at least 3')

    vertices = list(polygonVertices(x, y, radius, sides, rotationDegrees, stretchHorizontal, stretchVertical))

    if filled:
        # Run flood fill on the shape, starting from the center.
        borderPoints = list(lines(vertices, closed=True, thickness=thickness, endcap=None))
        return iter(floodFill(borderPoints, x, y))
    else:
        return lines(vertices, closed=True, thickness=thickness, endcap=None)