你们要的圣诞树,私信会不过来了,手麻了。 说明:需要先安装python,然后再创建.py文件,粘贴代码。用python去运行。
import turtle
def tree(d, s):
if d <= 0:
return
turtle.forward(s)
tree(d - 1, s * .8)
turtle.right(120)
tree(d - 3, s * .5)
turtle.right(120)
tree(d - 3, s * .5)
turtle.right(120)
turtle.backward(s)
n = 100
""" 设置绘图速度
'fastest' : 0
'fast' : 10
'normal' : 6
'slow' : 3
'slowest' : 1
"""
turtle.speed('fastest')
turtle.left(90)
turtle.forward(3 * n)
turtle.color("orange", "yellow")
turtle.left(126)
for i in range(5):
turtle.forward(n / 5)
turtle.right(144)
turtle.forward(n / 5)
turtle.left(72)
turtle.end_fill()
turtle.right(126)
turtle.color("dark green")
turtle.backward(n * 4.8)
tree(15, n)
turtle.backward(n / 5)
|