Commit 8650ce76 by BellCodeEditor

save project

parent da9f7c46
Showing with 11 additions and 3 deletions
import turtle import turtle
import random import random
import
l = ["snow","lightcoral"]
def tree(n): def tree(n):
if n >=0: if n >=0:
pen.pensize(n/10) lenth = random.randint(1,15)
if n <= 10:
pen.pensize(n)
a = random.choice(l)
pen.pencolor(a)
else:
pen.pencolor("sienna")
pen.pensize(n/10)
pen.forward(n) pen.forward(n)
angle = random.randint(0,30)#随机角度 angle = random.randint(0,30)#随机角度
lenth = random.randint(1,15)
pen.right(angle) pen.right(angle)
tree(n-lenth) tree(n-lenth)
pen.left(2*angle) pen.left(2*angle)
...@@ -25,5 +33,5 @@ pen.left(90) ...@@ -25,5 +33,5 @@ pen.left(90)
pen.up() pen.up()
pen.backward(150) # 后退 pen.backward(150) # 后退
pen.down() pen.down()
tree(50) tree(100)
turtle.done() turtle.done()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment