Commit a51ca92d by BellCodeEditor

save project

parent b2b7d20f
Showing with 20 additions and 7 deletions
import turtle
import random
pen = turtle.Turtle()
pen.speed(0)
pen.color('sienna')
# 画布大小
w = turtle.Screen()
......@@ -13,16 +16,26 @@ pen.backward(150) # 后退
pen.down()
def tree(n):
if n>=10:
if n>=0:
if n<=12:
color=['snow','lightcoral']
color=random.choice(color)
pen.color(color)
pen.pensize(n/3)
else:
pen.color('sienna')
pen.pensize(n/10)
pen.forward(n)
pen.right(30)
tree(n-10)
pen.left(60)
tree(n-10)
pen.right(30)
x=random.random()
pen.right(30*x)
c=1.5*random.random()
tree(n-10*c)
pen.left(60*x)
tree(n-10*c)
pen.right(30*x)
pen.up()
pen.backward(n)
pen.down()
tree(100)
tree(60)
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