Commit b3f8ed3a by BellCodeEditor

auto save

parent c29602d6
Showing with 17 additions and 2 deletions
import turtle
import random
def tree(n):
if n>=0:
if n<=12:
color_list=["snow","lightcoral"]
color=random.choice(color_list)
pen.color(color)
pen.pensize(n/3)
else:
pen.color("sienna")
pen.pensize(n/10)
pen.fd(n)
angle=random.randint(0,30)
length=random.randint(1,15)
pen.rt(angle)
length=random.randint(1,15)
tree(n-length)
pen.lt(2*angle)
tree(n-length)
......@@ -14,11 +26,13 @@ def tree(n):
pen.bk(n)
pen.down()
pen = turtle.Turtle()
pen.lt(90)
pen.color('sienna')
pen.speed(0)
# 画布大小
w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦
# 移动到起点
pen.lt(90)
tree(60)
turtle.done()
\ No newline at end of file
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