2022-10-06 16:13:06 +02:00
|
|
|
from uturtle import (
|
|
|
|
umonsTurtle, wait,
|
|
|
|
moveForward, moveBackward,
|
|
|
|
turnLeft, turnRight,
|
|
|
|
dropPen, usePen)
|
|
|
|
|
|
|
|
|
|
|
|
def carre(t: umonsTurtle, x: int, seuil: int):
|
|
|
|
"""draw an alternative to koch witch is based on squares"""
|
|
|
|
if x < seuil:
|
|
|
|
moveForward(t, x)
|
|
|
|
return
|
|
|
|
carre(t, x/3, seuil)
|
|
|
|
turnLeft(t)
|
|
|
|
carre(t, x/3, seuil)
|
|
|
|
turnRight(t)
|
|
|
|
carre(t, x/3, seuil)
|
|
|
|
turnRight(t)
|
|
|
|
carre(t, x/3, seuil)
|
|
|
|
turnLeft(t)
|
|
|
|
carre(t, x/3, seuil)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
turtle = umonsTurtle()
|
|
|
|
turtle.speed(0)
|
2022-11-24 09:49:57 +01:00
|
|
|
carre(turtle, 200, 5)
|
2022-10-06 16:13:06 +02:00
|
|
|
wait()
|