zoukankan      html  css  js  c++  java
  • turtle练习 分形树最终优化

    # 绘制分形树
    import turtle


    def draw_brach(brach_length):

    if brach_length > 5:
    turtle.pencolor("brown")
    turtle.pensize(3)
    turtle.forward(brach_length)
    turtle.right(30)
    draw_brach(brach_length - 15)

    turtle.left(60)
    draw_brach(brach_length - 15)

    turtle.right(30)
    turtle.up()
    turtle.backward(brach_length)
    turtle.down()
    if brach_length<=10:
    turtle.pencolor("green")
    turtle.pensize(5)
    turtle.forward(brach_length)
    turtle.right(30)
    draw_brach(brach_length - 15)

    turtle.left(60)
    draw_brach(brach_length - 15)

    turtle.right(30)
    turtle.up()
    turtle.backward(brach_length)
    turtle.down()


    def main():
    turtle.left(90)
    turtle.up()
    turtle.backward(200)
    turtle.down()
    turtle.pensize(10)
    draw_brach(100)
    turtle.exitonclick()
    if __name__ == '__main__':
    main()

  • 相关阅读:
    合并两个有序链表
    有效括号方法二
    有效括号
    es6 中的模块化
    XMLHttpRequest 对象
    AST
    php读写文件方式
    vue开发中遇到的问题
    sublime操作
    cmd命令
  • 原文地址:https://www.cnblogs.com/kwkk978113/p/10307014.html
Copyright © 2011-2022 走看看