python 画一颗简单的圣诞树
# -*- ecoding: utf-8 -*-
# @ModuleName: test008
# @Function: 一颗圣诞树
# @Author: darling
# @Time: 2021-12-22 11:12
from turtle import *
import random
import time
n = 80.0
speed("fastest")
screensize(bg='seashell')
left(90)
forward(3 * n)
color("orange", "red")
begin_fill()
left(126)
for i in range(5):
forward(n / 5)
right(144)
forward(n / 5)
left(72)
end_fill()
right(126)
color("dark green")
backward(n * 4.8)
def tree(d, s):
if d <= 0: return
forward(s)
tree(d - 1, s * .8)
right(120)
tree(d - 3, s * .5)
right(120)
tree(d - 3, s * .5)
right(120)
backward(s)
tree(15, n)
backward(n / 2)
for i in range(200):
a = 200 - 400 * random.random()
b = 10 - 20 * random.random()
up()
forward(b)
left(90)
forward(a)
down()
if random.randint(0, 1) == 0:
color('tomato')
else:
color('wheat')
circle(2)
up()
backward(a)
right(90)
backward(b)
time.sleep(60)
发现,等待下来的时间,有点长,想一想,是不是可以使用多线程进行循环?
惜秦皇汉武,略输文采;唐宗宋祖,稍逊风骚。
一代天骄,成吉思汗,只识弯弓射大雕。
俱往矣,数风流人物,还看今朝