tree design using python
from turtle import *
import colorsys
speed(0)
bgcolor("black")
hideturtle()
h = 0.8
def leaf():
fillcolor('green')
begin_fill()
circle(100,90)
lt(90)
circle(100,90)
end_fill()
def stem(length=500, width=12, stem_color="green"):
color(stem_color)
begin_fill()
for i in range(2):
forward(width)
right(90)
forward(length)
right(90)
end_fill()
# Draw Stem
stem()
rt(90)
fd(400)
rt(180)
leaf()
color("green")
fd(12)
lt(90)
fd(100)
rt(90)
leaf()
rt(90)
fd(12)
rt(90)
leaf()
color("green")
fd(12)
lt(90)
fd(300)
lt(90)
color("black")
lt(180)
lt(180)
fd(40)
rt(180)
lt(90)
fd(180)
rt(90)
for i in range(100):
c = colorsys.hsv_to_rgb(h, 1, 1)
color(c)
h += 0.005
begin_fill()
circle(180 - i, 100)
lt(100)
circle(180 - i, 100)
rt(100)
end_fill()
done()
from turtle import *
import colorsys
speed(0)
bgcolor('black')
pensize(5)
h=0.7
lt(90)
def tree(x):
global h
c=colorsys.hsv_to_rgb(h,1,1)
color(c)
h+=0.004
if(x<10):
return
else:
fd(x)
lt(30)
tree(3*x/4)
rt(60)
tree(3*x/4)
lt(30)
bk(x)
tree(70)
done()


Comments
Post a Comment