cours_progra/q1/04oct/ex4.py

28 lines
576 B
Python
Raw Permalink Normal View History

2022-10-06 16:13:06 +02:00
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)
2022-11-24 09:49:57 +01:00
flocon(turtle, 100, 6, sides=4)
2022-10-06 16:13:06 +02:00
wait()