cours_progra/04oct/ex4.py
2022-10-06 16:13:06 +02:00

28 lines
576 B
Python

from uturtle import (
umonsTurtle, wait,
moveForward, moveBackward,
turnLeft, turnRight,
dropPen, usePen)
from ex3 import koch
def flocon(t, x, seuil, sides=3):
"""draw a star with koch """
flocon_rec(t, x, seuil, sides, sides)
def flocon_rec(t, x, seuil, sides, i):
"""recursion function of flocon()"""
if i > 0:
koch(t, x, seuil)
turnRight(t, 360/sides)
flocon_rec(t, x, seuil, sides, i-1)
if __name__ == "__main__":
turtle = umonsTurtle()
turtle.speed(0)
flocon(turtle, 100, 5, sides=5)
wait()