Fix koch example
This commit is contained in:
parent
2ab650e364
commit
d70d57abca
1 changed files with 11 additions and 10 deletions
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue