You are on page 1of 2

from turtle import*

from random import*


from math import*
speed(0)
hideturtle()
setup(640,480)
up()
goto(-700,700)
down()
color('black', 'mintcream')
begin_fill()
for i in range(4):
forward(1400)
right(90)
end_fill()

def triangle(x,y,cote):
color('black', 'darkgreen')
begin_fill()
up()
goto(x,y)
down()
for i in range(3):
forward(cote)
left(120)
end_fill()

def tronc(x,y,n):
up()
goto(x,y)
forward(n/3)
down()
color('black', 'sienna')
begin_fill()
for i in range(4):
forward(n/3)
right(90)
end_fill()
up()

def sapin(x,y,n):
tronc(x,y,n)
for s in range(floor(n/40)):
triangle(x+s*15,y+s*50,n-s*30)

def foret(nb_arbre):
for i in range(nb_arbre):
x=randint(-350,200)
y=randint(-200,200)
cote=randint(100,200)
sapin(x,y,cote)
for i in range(5):
etoile(1,randint(5,40))

def etoile(nb,taille):
setheading(96)
for i in range(nb):
up()
goto(randint(-350,200),randint(-200,200))
down()
color('gold','yellow')
begin_fill()
for h in range(4):
right(15)
forward(taille)
left(15)
forward(-taille)
right(90)
end_fill()

foret(2)
exitonclick()

You might also like