Back to Turtle, and the full code for the fractal forest.
Been playing with yhe color choices...
from turtle import *
from random import *
screen = Screen()
screen.bgcolor('Misty Rose2')
t1 = Turtle()
t2 = Turtle()
t3 = Turtle()
t4 = Turtle()
t5 = Turtle()
x = -200
turtles = [t1,t2,t3,t4,t5]
for t in turtles:
t.speed(100)
t.left(90)
t.color('sienna1')
t.pu()
x += randint(80,160)
t.goto(x, randint(-100,10))
t.pd()
def branch(turt, branch_len):
angle = randint(22,30)
sf = uniform(0.6,0.8)
size = int(branch_len /10)
turt.pensize(size)
if branch_len < 20:
turt.color('spring green')
turt.stamp()
turt.color('sienna1')
if branch_len > 10:
turt.forward(branch_len)
turt.left(angle)
branch(turt, branch_len*sf)
turt.right(angle*2)
branch(turt, branch_len*sf)
turt.left(angle)
turt.backward(branch_len)
for t in turtles:
branch(t,100)
exitonclick()
To access the code, click Show Files:
https://replit.com/@SanjinDedic/forrestFractalTrees
* * *
Surely not a coincidence. The 72 year old man who created havoc at events for the
Chinese New Year might have been born in1950, a Year of the Tiger ending on
January 22, 2023. Or might have been born early 1951, and thus a Rabbit, like the
coming year.
In the first case, a tiger is a natural leader and very brave. He dispenses justice.
A rabbit is very outgoing. If we are in a person's birth sign year, they are expected
to take the initiative.
Either way...
* * *
No comments:
Post a Comment