科赫曲线V1
# 科赫雪花1# KochDrawV1
import turtle as t
def koch(size, n):
if n == 0:
t.fd(size)
else:
for angle in :
t.left(angle)
koch(size/3,n-1)
def main():
t.setup(600, 600)
t.penup()
t.goto(-200,100)
t.pendown()
t.pensize(2)
t.pencolor('purple')
level = 5
koch(400,level)# 绘制三阶科赫曲线
t.right(120)
koch(400, level)
t.right(120)
koch(400, level)
t.hideturtle()
t.done()
main()
页:
[1]