38 lines
710 B
Python
38 lines
710 B
Python
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)
|
|
return
|
|
|
|
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, 1)
|
|
wait()
|