就是比之前的多个彩色而已
# -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
import turtle
import time
import math
import random
import turtle as t
t.colormode(255)
turtle.bgcolor("white")
angle = 0
h=255
def wuxing():
turtle.pu()
r=100#半径
#turtle.penup()
turtle.goto(0, 0) # 到画布中心
turtle.setheading(angle) # 设置当前朝向为angle角度
#turtle.stamp()#central
turtle.fd(r)
#turtle.right(90)
text="劳动节快乐"
#turtle.pu()
x=len(text)
turtle.rt(180-(x-2)*180/x/2)#n边形内角和公式
#turtle.stamp()
for i in text:
e=random.randint(0,h)
f=random.randint(0,h)
g=random.randint(0,h)
turtle.pencolor(e,f,g)
turtle.write(i,font=('隶书',40))
a=2*r*math.sin(math.pi/x)#radian
#这边理论上是乘以2的,但是不知道为什么不绕着圆心转,可能writen函数怪怪的
turtle.fd(a)
turtle.rt(360/x)
turtle.hideturtle()
turtle.tracer(0.1) # 将刷新率置为0,即不刷新
for j in range(5000): # 这里设置了1w次,也可以是其他次数
wuxing()
turtle.update() # 更新绘图
time.sleep(0.01) # 休眠时间,这一句可以没有,但是如果没有的话,转的会很快
turtle.clear() # 清空画布
angle -= 1
声明:著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。