# KochDraw.pyimport turtle # koch: 绘制n阶科赫曲线# main: 绘制科赫雪花‘‘‘安装第三方库: 命令行下输入pip install pyinstaller打包KochDraw.py为可执行文件 命令行下输入pyinstaller -F KochDraw.py‘‘‘ def koch(size, n): if n == 0: turtle.fd(size) else: koch(size / 3, n-1) turtle.left(60) koch(size / 3, n - 1) turtle.right(120) koch(size / 3, n-1) turtle.left(60) koch(size / 3, n - 1) def main(size, n): turtle.speed(0) turtle.penup() turtle.goto(-200, 100) turtle.pendown() koch(size, n) turtle.right(120) koch(size, n) turtle.right(120) koch(size, n) turtle.hideturtle() turtle.done() main(300, 3)
原文地址:https://www.cnblogs.com/wumingoo1/p/10322625.html
时间: 2024-11-08 23:48:05