cours_progra/bac1/q1/04oct/ex4.py
Debucquoy 4fd7542f03
.
2023-09-20 15:18:20 +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, 6, sides=4)
wait()