左手画龙右手画彩虹听说很火,Python也可以画出很美的彩虹,准确的说像彩虹棒棒糖:)
效果如下图:
# -*- coding: utf-8 -*-
# @Time : 2019/12/16 23:28
# @Author : Nola
# @File : pen_something.py
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
sides = 6 # 绘制6个边
colors = ["red", "yellow", "green", "blue", "orange", "purple"]
for x in range(360):
t.pencolor(colors[x % sides])
t.forward(x * 3 / sides + x)
t.left(360 / sides + 1)
t.width(x * sides / 180)
t.left(91)