大家好,小编来为大家解答以下问题,用python绘制满天星动态,用python画满天星花朵,现在让我们一起来看看吧!
import turtle as t
import random
t.pensize(1)
t.screensize(800,800,'black')
def stars(x,y,left_angle,edge_len):
t.pencolor('yellow')
t.fillcolor('yellow')
t.penup()
t.goto(x,y)
t.begin_fill()
t.pendown()
t.left(left_angle)
for _ in range(5):
t.forward(edge_len)
t.right(144)
t.end_fill()
for _ in range(300):
x=random.randint(-450,450)
y=random.randint(0,400)
edge_len=random.randint(3,8)
left_angle=random.randint(0,180)
stars(x,y,left_angle,edge_len)