Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from graphics import *
- import math
- from random import randint
- winS = 700
- win = GraphWin("Tree", winS, winS)
- def sin(a):
- return math.sin(math.radians(a))
- def cos(a):
- return math.cos(math.radians(a))
- def tree(i,a,b=60,r=270,x=winS//2,y=winS-30):
- if a <= 0 or b < 2:
- return
- xx = round(cos(r) * b)
- yy = round(sin(r) * b)
- s = Line(Point(x, y), Point( x + xx, y + yy))
- s.draw(win)
- s.setWidth(a//1.5)
- i = randint(-30,30)
- tree(i, a-1, b , r + i, x + xx, y + yy)
- if i%2==0:
- tree(i, a-1, b , r - i, x + xx, y + yy)
- tree(10,20,16,270)
- while True:
- update(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement