五角星铺的彩图

0

from turtle import *
from random import randint,choice

def draw_star(a,length):
"""
a:海龟
length:边长
"""
a.begin_fill()
for x in range(5):
a.fd(length)
a.left(144)
a.end_fill()

cs = ['red','pink','orange','yellow','cyan','green','purple','blue']

screen = Screen()
screen.bgcolor('black')

t = Turtle()
t.penup()
while True:
x = randint(-300,300)
y = randint(-300,300)
t.goto(x,y)
c = choice(cs)
t.fillcolor(c)
d = randint(10,50)
draw_star(t,d)

0

发表评论