画绿树_Python漂亮的二叉分形递归树

画绿树Python漂亮的二叉分形树递归

画绿树Python漂亮的二叉分形树递归

"""
   画绿树,本程序要用到coloradd模块,安装方法为在命令提示符下输入:
   pip install coloradd,它能让RGB 255三元组颜色进行增加,就像scratch中的颜色增加命令一样.
""""
   
from turtle import *
from coloradd import *

def draw_tree(t,n,distance):
    """画二叉树的函数"""
    if n > 0:
        t.fd(distance)
        t.left(45)
        draw_tree(t,n-1,distance-20)
        t.right(90)
        draw_tree(t,n-1,distance-20)
        t.left(45)
        t.bk(distance)

screen = Screen()
screen.colormode(255)
screen.title("画绿树by www.lixingqiu.com")
screen.tracer(0)

t = Turtle(visible=False)
t.left(90)
t.bk(100)

color = (29,195,10)               # 起始颜色
width = 100

You must log in to read the rest of this article. Please log in or register as a user.