from turtle import *
speed('fastest')
# turning the turtle to face upwards
rt(-90)
# the base and branch of the Y
angle = 30
# function to plot a Y
def y(sz, level):
if level > 0:
colormode(255)
pencolor(0, 255//level, 0)
fd(sz)
rt(angle)
# recursive call
y(0.8 * sz, level-1)
pencolor(0, 255//level, 0)
lt( 2 * angle )
y(0.8 * sz, level-1)
pencolor(0, 255//level, 0)
rt(angle)
fd(-sz)
y(80, 7)
No comments:
Post a Comment