Fix koch example

This commit is contained in:
Scott Shawcroft 2023-04-19 10:55:38 -07:00 committed by GitHub
parent 2ab650e364
commit d70d57abca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,9 @@ from adafruit_turtle import turtle
def f(side_length, depth, generation): def f(side_length, depth, generation):
if depth != 0: if depth == 0:
turtle.forward(side_length)
return
side = lambda: f(side_length / 3, depth - 1, generation + 1) side = lambda: f(side_length / 3, depth - 1, generation + 1)
side() side()
turtle.left(60) turtle.left(60)
@ -23,7 +25,6 @@ turtle = turtle(board.DISPLAY)
unit = min(board.DISPLAY.width / 3, board.DISPLAY.height / 4) unit = min(board.DISPLAY.width / 3, board.DISPLAY.height / 4)
top_len = unit * 3 top_len = unit * 3
print(top_len)
turtle.penup() turtle.penup()
turtle.goto(-1.5 * unit, unit) turtle.goto(-1.5 * unit, unit)
turtle.pendown() turtle.pendown()