from graphics import *
from math import *

def drawTree(win,x,y,size,angle):
    if size > 2:
        x2 = x + size * cos(angle)
        y2 = y + size * sin(angle)
        line = Line(Point(x,y),Point(x2,y2))
        line.setWidth(3)
        line.setOutline("brown")
        line.setFill("brown")
        line.draw(win)
        drawTree(win,x2,y2,size*0.75,angle+pi/6)
        drawTree(win,x2,y2,size*0.66,angle-pi/4)
                 
def main():
    win = GraphWin("Tree",1000,1000)
    win.setCoords(0,0,1000,1000)
    ground = Rectangle(Point(0,0),Point(1000,200))
    ground.draw(win)
    ground.setFill("green")
    win.setBackground(color_rgb(200,200,255))
    win.getMouse()
    drawTree(win,500,150,200,pi/2)
    win.getMouse()
    
main()
