Python画八字彩环图形

"""Python画八字彩环图形,本程序用到了coloradd模块,可以从pip install coloradd安装"""

import turtle
from coloradd import *

screen = turtle.getscreen()       # 获取屏幕对象
screen.bgcolor("black")           # 设置屏幕背景
screen.delay(0)                   # 设置绘画延时 
screen.setup(480,360)             # 设置画布大小
screen.title("python8字彩环www.lixingqiu.com")

turtle.setheading(180)            # 设置初始方向
turtle.pensize(6)                 # 设置画笔大小

color = (1,0,0)                   # 设置初始颜色

for _ in range(36):
    for i in range(10):
        color = coloradd(color,0.01)
        turtle.pencolor(color)
        turtle.fd(10)
        turtle.left(18)
    for i in range(20):
        color = coloradd(color,0.01)
        turtle.pencolor(color)
        turtle.fd(10)
        turtle.right(18)
    for i in range(10):
        color = coloradd(color,0.01)
        turtle.pencolor(color)
        turtle.fd(10)
        turtle.left(18)
    turtle.left(10)
    
screen.mainloop()

Python画八字彩环图形