Commit a46d2558 by BellCodeEditor

auto save

parent a075876f
Showing with 20 additions and 0 deletions
import turtle
import random
#随机树杈角度 随机树干长度 慢慢变小树枝
turtle.speed(0)
def tree(n): #90 80
if n>=20:
pen.pensize(n/10)
a=random.randint(1,30)
b=random.randint(1,15)
pen.fd(n)
pen.right(a)
tree(n-b)
pen.left(a*2)
tree(n-b) # tree(100-10) tree(90-10)
pen.right(a)
pen.up()
pen.backward(n)
pen.down()
pen = turtle.Turtle()
pen.color('sienna')
......@@ -12,4 +30,6 @@ pen.up()
pen.backward(150) # 后退
pen.down()
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