Commit 6548953d by BellCodeEditor

save project

parent 32794583
Showing with 16 additions and 4 deletions
import turtle import turtle
import random
pen = turtle.Turtle() pen = turtle.Turtle()
pen.color('sienna') pen.color('sienna')
# 画布大小 # 画布大小
...@@ -7,9 +7,21 @@ w = turtle.Screen() ...@@ -7,9 +7,21 @@ w = turtle.Screen()
w.bgcolor('wheat') # wheat小麦 w.bgcolor('wheat') # wheat小麦
def tree(n): def tree(n):
if n>=25: if n>=13:
length=random.random(10,30)
pen.pensize(n/10)
pen.color('sienna')
pen.forward(n)
pen.right(30)
tree(n/2)
pen.left(30)
pen.left(30)
tree(n/2)
pen.right(30)
pen.backward(n)
else:
pen.pencolor("snow")
pen.pensize(n/3)
# 移动到起点 # 移动到起点
pen.left(90) pen.left(90)
pen.backward(100) pen.backward(100)
......
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