大家好,给大家分享一下Python烟花代码可以在微信中打开吗,很多人还不知道这一点。下面详细解释一下。现在让我们来看看!
# -*- coding: utf-8 -*-
import math, random,time
import threading
import tkinter as tk
import re
#import uuid
Fireworks=[]
maxFireworks=8
height,width=600,600
class firework(object):
def __init__(self,color,speed,width,height):
#uid=uuid.uuid1()
self.radius=random.randint(2,4) #粒子半径为2~4像素
self.color=color #粒子颜色
self.speed=speed #speed是1.5-3.5秒
self.status=0 #在烟花未爆炸的情况下,status=0;爆炸后,status>=1;当status>100时,烟花的生命期终止
self.nParticle=random.randint(20,30) #粒子数量
self.center=[random.randint(0,width-1),random.randint(0,height-1)] #烟花随机中心坐标
self.oneParticle=[] #原始粒子坐标(100%状态时)
self.rotTheta=random.uniform(0,2*math.pi) #椭圆平面旋转角
#椭圆参数方程:x=a*cos(theta),y&