Commit f552c7fc by BellCodeEditor

save project

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