python海龟画图生成星星
import turtle as tt
import random
from random import randint
tt.setup(1280,720)
tt.bgcolor("black")
tt.colormode(255)
tt.speed(0)
q = 1
while q <= 1000:
B = randint(0, 255)
x = randint(-640, 640)
y = randint(-360, 360)
A = randint(0, 255)
B = randint(0, 255)
C = randint(0, 255)
tt.pencolor(A, B, C)
tt.pu()
tt.goto(x,y)
tt.pd()
a = ['red','yellow','blue','green','pink','purple','pink','white','cyan','gray','coral']
tt.fillcolor(random.choice(a))
tt.begin_fill()
for i in range(6):
tt.forward(15)
tt.left(144)
tt.hideturtle()
q = q + 1
tt.end_fill()
tt.done()
运行效果图:
以上是 python海龟画图生成星星 的全部内容, 来源链接: utcz.com/z/388924.html