''' Happy Trees Pylie.com Sandbox ''' import turtle import random def tree(branchLen,t, d): if branchLen > 5: t.forward(branchLen) t.right(10) if (branchLen-20) < 25: t.color((255,40*d,150*d), (34,139,34)) tree(branchLen-20-5*d,t,d) t.left(30) tree(branchLen-15-10*d,t,d) t.right(20+1*d) t.backward(branchLen) t.color((200*d,139,100*d), (34,139,34)) t.left(1*d) def main(): t = turtle.Turtle() t.shape('turtle') t.color((200,139,100),(34,139,34)) t.left(90) t.up() t.speed(2) t.backward(200) t.speed(10) t.down() x_list = range(-500,500,100) x_list = [(x + random.random()*30) for x in x_list] random.shuffle(x_list) for x in x_list: t.up() t.setx(x) t.sety(-200+(70*random.random() - 70*random.random())) t.down() d = random.random() t.color((200*d,139,100*d),(34,139,34)) tree(25+(110*d),t, d) t.up() t.setx(-500) t.sety(-250) t.write('Laki, the Painter ', True, align="center", font=("Times New Roman", 11, "italic")) main() print 'End'
اجرا کن
پاک کن