彩色多线程旋转雪花

from turtle import Screen,Turtle  # 从海龟画图导入Screen函数和Turtle类
import threading
from time import sleep


def draw_snow(length,level):      # 画雪花递归函数
    if level == 0 : return        #level为零则返回
    for i in range(8):            #  重复8次  
        t.fd(length)              # 前进length 
        draw_snow(length/4,level-1) # 画length/4的雪花
        t.bk(length)              # 隔退length
        t.rt(45)                  # 右转45度
        
class Snow(Turtle):
    def __init__(self,x,y,color):
        Turtle.__init__(self,visible=False,shape = 'snow')
        self.penup()        
        self.color(color)          # 设定画笔颜色为color
        self.goto(x,y)             # 定位到x,y坐标
        self.anglespeed = 10       # 每次旋转的角度
        self.st()                  # 显示
        self.threading = threading.Thread(target=self.rotate) # 创建线程
        self.threading.setDaemon(True) # 设置为守护线程
        self.threading.start()         # 启动这个线程
 

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