Commit f552c7fc by BellCodeEditor

save project

parent 267e7997
Showing with 18 additions and 7 deletions
import turtle
import random
def tree(n):
if n>=50:
if n>=0:
if n<=12:
pen.color("lightcoral")
pen.pensize(n/3)
else:
pen.color("sienna")
pen.pensize(n/10)
pen.forward(n)
pen.right(30)
tree(n-50)
pen.left(60)
tree(n-50)
pen.right(30)
a=random.randint(0,30)
b=random.randint(0,15)
pen.right(a)
tree(n-b)
pen.left(a*2)
tree(n-b)
pen.right(a)
pen.penup()
pen.forward(-n)
pen.pendown()
pen.down()
pen = turtle.Turtle()
pen.speed(0)
pen.color('sienna')
# 画布大小
w = turtle.Screen()
......@@ -22,7 +33,7 @@ pen.left(90)
pen.penup()
pen.forward(-150) # 后退
pen.pendown()
tree(100)
tree(60)
# pen.forward(100)
# pen.right(30)
......
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