目錄python
高大上的分形幾何框架
科赫曲線,也叫雪花曲線ide
# KochDrawV1.py import turtle def koch(size, n): if n == 0: turtle.fd(size) else: for angle in [0, 60, -120, 60]: turtle.left(angle) koch(size / 3, n - 1) def main(): turtle.setup(800, 400) turtle.penup() turtle.goto(-300, -50) turtle.pendown() turtle.pensize(2) koch(600, 3) # 3階科赫曲線,階數 turtle.hideturtle() main()
# KochDrawV1.py import turtle def koch(size, n): if n == 0: turtle.fd(size) else: for angle in [0, 60, -120, 60]: turtle.left(angle) koch(size / 3, n - 1) def main(): turtle.setup(600,600) urtle.penup() turtle.goto(-200, 100) turtle.pendown() turtle.pensize(2) level = 3 # 3階科赫雪花,階數 koch(400, level) turtle.right(120) koch(400, level) turtle.right(120) koch(400, level) turtle.hideturtle() main()
打包才能上路…函數
pyinstaller –i curve.ico –F KochDrawV2.py
3d