程序代码:
import turtle as t #将turtle库给予别名t
from random import randint
t.setup(800, 1000, 0, 0)
t.speed(0)
t.fillcolor("purple")
# 病毒的外框
t.begin_fill()
for i in range(6):
t.circle(200, 30)
t.right(50)
t.fd(100)
t.left(90)
t.circle(30, 30)
t.left(45)
t.fd(80)
t.right(90)
if i == 5:
t.circle(200, 30)
t.end_fill()
# 病毒内里面的圆
t.fillcolor("gray")
for i in range(4):
t.penup()
t.left(90)
if i == 0:
t.fd(180)
else:
t.fd(randint(50, 100)) # 随机距离
t.pendown()
t.begin_fill()
t.circle(12, 360)
t.end_fill()
t.penup()
t.goto(200,300)
t.pendown()
t.write('新冠病毒',font=("Arial",34,"normal"))
# 画框一直存在
t.done()