Commit f4ff98a1 by BellCodeEditor

auto save

parent 0cc37ad4
Showing with 37 additions and 0 deletions
import turtle
import random
# 设置画布大小和背景颜色
turtle.setup(800, 600)
turtle.bgcolor("black")
# 定义雪花的形状和颜色
snowflake_shape = [(0, 0), (0.6, 0.6), (0.6, 0), (0, 0)]
snowflake_color = [(255, 255, 255), (255, 255, 255), (255, 255, 255), (255, 255, 255)]
# 定义雪花的数量和位置
num_snowflakes = 50
x = random.randint(-400, 400)
y = random.randint(-300, 300)
for i in range(num_snowflakes):
# 随机选择雪花的颜色和位置
snowflake_color[i] = random.choice(snowflake_color)
snowflake_shape[i][0] = x
snowflake_shape[i][1] = y
# 将雪花添加到画布上
turtle.penup()
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()
turtle.color(snowflake_color[i])
for side in snowflake_shape:
turtle.forward(side[0])
turtle.right(random.randint(0, 360))
turtle.end_fill()
# 隐藏画笔
turtle.hideturtle()
# 等待用户关闭窗口
turtle.done()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment