彩色的五角星

0

from turtle import Turtle,Screen
from random import randint,choice

def draw_star(t,length):
    t.begin_fill()
    for x in range(5):
        t.fd(length)
        t.left(144)
    t.end_fill()

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

screen=Screen()
screen.bgcolor('black')
screen.delay(0)
w=screen.window_width()
h=screen.window_height()

jack=Turtle()
jack.speed(0)
while True:
    x=randint(-w//2,w//2)
    y=randint(-h//2,h//2)
    jack.penup()
    jack.goto(x,y)
    jack.color(choice(cs))
    jack.pendown()
    d=randint(10,60)
    draw_star(jack,d) 


0

发表评论