from turtle import *
#控制彩虹路径
def path(pen, r, g, b):
pen.penup()
pen.goto(-400, -300)
pen.pendown()
pen.pencolor(r, g, b)
pen.circle(1000, -180)
pen.pensize(2)
pen.right(0.05)
#绘制彩虹控制颜色
def Rainbow():
pen = Turtle()
pen.right(110)
r = 255
g = 0
b = 0
interval = 5
colormode(255)
# 由红到黄
while g < 256:
path(pen, r, g, b)
g = g + interval
#由黄到绿
g = 255
while r > 0:
r = r - interval
path(pen, r, g, b)
#由绿到青
r = 0
while (b < 255 ):
b = b + interval
path(pen, r, g, b)
b = 255
#由青到蓝
while (g > 0):
g = g - i
Python学习之绘制彩虹图
最新推荐文章于 2024-07-02 12:39:30 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)