Árvores incríveis com tartaruga python
from random import *
from turtle import *
t1, t2, t3, t4, t5 = Turtle(), Turtle(), Turtle(), Turtle(), Turtle()
turtles = [t1, t2, t3, t4, t5]
x = -200
for t in turtles:
x += randint(60, 160)
y = randint(-200, -100)
t.speed(100)
t.lt(90)
t.color('brown')
t.up()
t.goto(x, y)
t.down()
def branch(turt, branch_len, angle):
angle = randint(22, 30)
sf = uniform(0.6, 0.8)
size = branch_len / 10
turt.pensize(size)
if branch_len < 20:
turt.color('forest green')
turt.stamp()
turt.color('brown')
if branch_len > 10:
turt.fd(branch_len)
turt.lt(angle)
branch(turt, branch_len * sf, angle)
turt.rt(angle * 2)
branch(turt, branch_len * sf, angle)
turt.lt(angle)
turt.bk(branch_len)
for t in turtles:
branch(t, 100, 30)
Screen().exitonclick()
Nervous Nightingale