画某沙漏

2+
from turtle import Turtle,Screen
screen = Screen()
screen.delay(0)
def draw_polygon(haigui,n,length,k):
  for x in range(n):
    haigui.fd(length)
    haigui.left(k * 360/n)
screen.bgcolor('black')
cs = ['red','orange','yellow','green','cyan','blue','purple','pink']
t = Turtle()
t.pensize(10)
t.speed(0)
for i in range(100):
  for n in range(3,10):
    t.pencolor(cs[n-3])
    draw_polygon(t,n,100,1)
  for n in range(3,10):
    t.pencolor(cs[n-3])
    draw_polygon(t,n,100,-1)  
  t.right(7)

2+

发表评论