python纯画笔大雪纷飞景像模拟

"""
   python纯画笔大雪纷飞景像模拟.py
   注意本程序虽然海龟移动了,但重点在于演示它画的点在移动,
   所以叫纯画笔动画。 
"""

import time
from turtle import * 
from random import randint
 
width,height = 960,720

screen = Screen()
screen.bgcolor("black")
screen.title("python纯画笔大雪纷飞景像模拟")
screen.setup(width,height)
screen.tracer(0)           # 关闭自动刷新

m = Turtle(visible=False)
m.color('white')
m.up()                     # 抬笔
m.ht()                     # 和本身形状无关,所以隐藏
m.dx = randint(0,2)        # 自定义属性,单位水平位移
m.dy = randint(-20,-10)    # 单位垂直位移

ts = [m.clone() for i in range(330)]

[t.sety(randint(height//2,height*2)) for t in ts]

for t in ts:
    t.setx(randint(-width//2,width//2))
    t.dx = randint(-1,1)
    t.dy = randint(-20,-10) 

You must log in to read the rest of this article. Please log in or register as a user.