|
“你是我的今日,以及所有的明天”环境PythonPyCharm完整程序importtkinterastkimporttkinter.messageboximportrandomfrommathimportsin,cos,pi,logfromtkinter.constantsimport*width=888height=500heartx=width/2hearty=height/2side=11heartcolor="pink"#爱心颜色,可修改classHeart:def__init__(self,generate_frame=20):self._points=set()#原始爱心坐标集合self._edge_diffusion_points=set()#边缘扩散效果点坐标集合self._center_diffusion_points=set()#中心扩散效果点坐标集合self.all_points={}#每帧动态点坐标self.build(2000)self.random_halo=1000self.generate_frame=generate_frameforframeinrange(generate_frame):self.calc(frame)defbuild(self,number):for_inrange(number):t=random.uniform(0,2*pi)x,y=heart_function(t)self._points.add((x,y))for_x,_yinlist(self._points):for_inrange(3):x,y=scatter_inside(_x,_y,0.05)self._edge_diffusion_points.add((x,y))point_list=list(self._points)for_inrange(4000):x,y=random.choice(point_list)x,y=scatter_inside(x,y,0.17)self._center_diffusion_points.add((x,y))@staticmethoddefcalc_position(x
|
|