from uturtle import (
    umonsTurtle, wait,
    moveForward, moveBackward,
    turnLeft, turnRight,
    dropPen, usePen)


def koch(t: umonsTurtle, x: int, seuil: int):
    """Dessine une courbe de koch

    :t: the turtle used
    :x: the length
    :seuil: seuil of smallest step
    :returns: None

    """
    if x < seuil:
        moveForward(t, x)
    else:
        koch(t, x/3, seuil)
        turnLeft(t, 60)
        koch(t, x/3, seuil)
        turnRight(t, 120)
        koch(t, x/3, seuil)
        turnLeft(t, 60)
        koch(t, x/3, seuil)


if __name__ == "__main__":
    turtle = umonsTurtle()
    turtle.speed(0)
    dropPen(turtle)
    moveBackward(turtle, 250)
    usePen(turtle)
    koch(turtle, 500, 20)
    wait()
