Turtle Graphics
Turtle Graphics
import turtle
import colorsys
wn=turtle.Screen()
t=turtle.Turtle()
wn.setup(width=1080,height=2129,startx=0,starty=-1)
wn.bgcolor("black")
wn.tracer(500)
t.pensize(5)
t.up()
t.goto(0,700)
t.down()
t.pencolor("red")
t.write("TURTLE GRAPHICS",align="center",font=("Impact",18,"bold"))
t.up()
t.goto(100,100)
t.down()
h=1
def tree(length, angle):
global h
c=colorsys.hsv_to_rgb(h,1,1)
t.pencolor(c)
if (length < 3):
return
t.right(-angle)
t.forward(length)
tree(length//1.61803, angle)
t.right(180)
t.forward (length)
t.right(180)
t.right(2*angle)
t.forward(length)
tree(length//1.61803, angle)
t.right(180)
t.forward (length)
t.right(180)
t.left(angle)
h+=0.001
while True:
tree(69,61)
t.rt(60)
t.fd(150)
wn.mainloop()
Comments
Post a Comment