彩色粒子效果克隆动画
11月 27, 2019
0 Comments

以下是部分代码预览:
""" 彩色粒子效果克隆动画.py 本程序产生了炫丽的彩色粒子效果,亮点:如何彻底删除一个海龟对象。 要不然程序会越来越卡! Delete thoroughly python turtle object,designer: lixingqiu。 """ import colorsys from random import * from turtle import * class Particle(Turtle): """继承自海龟的粒子类""" def __init__(self): """初始化方法""" Turtle.__init__(self,visible=False,shape='circle') self.penup() self._scale = 0.1 self.shapesize(0.1,0.1) r = [ i for i in range(-25,26) if i != 0] self.goto(choice(r),choice(r)) pass self.color(choice(cs)) self.speed = self.distance(0,0)/10 self.st() def move(self): """向前移动""" self.speed = self.distance(0,0)/10 self.fd(self.speed) pass # 以下是产生颜色表 cs = [] for y in range(100): x = random() r,g,b = colorsys.hsv_to_rgb(x,1,1) r,g,b = int(r*255),int(g*255),int(b*255) cs.append((r,g,b)) width,height = 800,600 screen = Screen() screen.setup(width,height) screen.tracer(0,0) screen.colormode(255) screen.bgcolor('black') pass
如需要下载完整源代码及素材,请
需要浏览更多吗?
成为会员后,登陆才能继续浏览!联系微信scratch8即可办理会员。
(会员专属:能浏览所有文章,下载所有带链接的Python资源。)