def tick(self): self.offset += 1 if self.offset == self.cube.size: self.color = cubehelper.random_color() self.offset = 1 - self.cube.size self.phase += 1 if self.phase == 3: self.phase = 0 raise StopIteration p0 = self.phase p1 = (p0 + 1) % 3 p2 = (p1 + 1) % 3 pos = [0]*3 off = [0]*3 on = [0]*3 on[p0] = 255 for i in range(0, self.cube.size): if i == self.cube.size - (abs(self.offset) + 1): color = self.color else: color = off pos[p0] = i for j in range(0, self.cube.size): pos[p1] = j for k in range(0, self.cube.size): pos[p2] = k self.cube.set_pixel(pos, color)
def tick(self): self.cube.clear() if self.position == 0: if self.message == '': self.message = self.saved_message raise StopIteration c = self.message[0] self.message = self.message[1:] n = ord(c) - 32 if n >= 0 and n < len(font.font_data): self.data = font.font_data[n] else: self.data = () self.color = cubehelper.random_color() x = (self.cube.size - len(self.data)) // 2 y = self.position for mask in self.data: for z in range(0, 8): if mask & (0x80 >> z): color = self.color else: color = (0,0,0) self.cube.set_pixel((x, y, z), color) x += 1 self.position += 1 if self.position == self.cube.size: self.position = 0
def init(self): self.filling_color = cubehelper.random_color() self.offset = 0 # how far from the corner to draw self.double_buffered = True # Vertices: # bottom layer # 2--6 # | | # 0--4 # # top layer # 3--7 # | | # 1--5 cs = self.cube.size-1 self.corners = [ [(0, 0, 0), (1, 1, 1)], # 0 [(0, 0, cs), (1, 1, -1)], # 1 [(0, cs, 0), (1, -1, 1)], # 2 [(0, cs, cs), (1, -1, -1)], # 3 [(cs, 0, 0), (-1, 1, 1)], # 4 [(cs, 0, cs), (-1, 1, -1)], # 5 [(cs, cs, 0), (-1, -1, 1)], # 6 [(cs, cs, cs), (-1, -1, -1)], # 7 ] self.black = (0.0, 0.0, 0.0) self.corner = self.corners[random.randrange(0, 8)] # the current corner we're filling from return 0.6 / self.cube.size
def init(self): self.direction = 1 # 1=shrink, -1=expand self.current_size = 0 # size is distance from edge of cube, not distance from centre self.max_size = (self.cube.size - 1) // 2 self.color = cubehelper.random_color() self.double_buffer = True return 1.0 / self.cube.size
def restart(self): self.offset = 0 new_corner_index = self.corner_index while self.corner_index == new_corner_index: new_corner_index = random.randrange(0, 8) self.corner_index = new_corner_index self.corner = self.corners[self.corner_index] self.filling_color = cubehelper.random_color(self.filling_color)
def init(self): self.message = 'Leeds Hackspace' self.position = 0 self.double_buffer = True self.pos = [pos for pos in walker(self.cube)] self.bitmap = [0] * len(self.pos) self.color = cubehelper.random_color() return 0.5 / self.cube.size
def tick(self): # Draw the cube at its current size, then reduce the size for the next iteration self.cube.clear() self.draw_cube(self.current_size, self.color) self.current_size += self.direction if self.current_size == 0: self.direction *= -1 raise StopIteration elif self.current_size == self.max_size: self.direction *= -1 self.color = cubehelper.random_color(self.color)
def tick(self): if self.counter > (self.cube.size * self.cube.size): raise StopIteration; self.counter += 1; self.cube.clear() # sine needs 0 to be midpoint... ah. but there's no midpoint for x in range(0, self.cube.size): y = int(math.sin(x+self.counter) * self.cube.size/2); y += self.cube.size//2 z = int(math.sin(x+self.counter-1) * self.cube.size/2); z += self.cube.size//2 color = cubehelper.random_color() self.cube.set_pixel([x,z,y],color);
def tick(self): color = cubehelper.mix_color((0.0,0.0,0.0), self.color, self.level) for y in range(0, self.cube.size): for z in range(0, self.cube.size): for x in range(0, self.cube.size): self.cube.set_pixel((x, y, z), color) self.level += self.delta if self.level >= 1.0: self.delta = -self.delta self.level = 1.0 if self.level <= 0.0: self.delta = -self.delta self.level = 0.0 self.color = cubehelper.random_color() raise StopIteration
def tick(self): if (self.offset < self.cube.size): self.draw_cubeface(self.corner, self.offset, self.filling_color) # now cover it over with black o = self.offset - 5 if o >= 0: self.draw_cubeface(self.corner, o, self.black) if o == self.cube.size-1: self.offset = 0 self.corner = self.corners[random.randrange(0, 8)] self.filling_color = cubehelper.random_color(self.filling_color) else: self.offset += 1
def init(self): self.phase = 0 self.offset = -self.cube.size self.color = cubehelper.random_color() return 1.0 / self.cube.size
def explode(self): self.bit_color = cubehelper.random_color() self.bits = [self.spawn_bit(i) for i in range(0, 20)] self.fade = 1.0 self.rocket = None
def set_colour(self, c=None): if c is None: c = cubehelper.random_color() self.colour = c
def restart(self): self.offset = 0 self.corner = self.corners[random.randrange(0, 8)] self.filling_color = cubehelper.random_color(self.filling_color)
def reset(self): self.bitmap = [0] * len(self.pos) self.message = self.saved_message self.color = cubehelper.random_color()
def init(self): self.level = 0.0 self.delta = 1.0/16 self.color = cubehelper.random_color() return 1.0/16
def restart(self): self.lineanim = [ [ [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1], [0,0,0,0,0,0,0,1] ], [ [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0], [0,0,0,0,0,0,0,1] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0], [0,0,0,0,0,0,1,0] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0], [0,0,0,0,0,1,0,0] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0], [0,0,0,0,1,0,0,0] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0], [0,0,0,1,0,0,0,0] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0], [0,0,1,0,0,0,0,0] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [0,1,0,0,0,0,0,0] ], [ [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0], [1,0,0,0,0,0,0,0] ], ] self.filling_color = 0 self.red = (2.0,0.0,0.0) self.green = (0.0,2.0,0.0) self.blue = (0.0,0.0,2.0) self.off = (0.0,0.0,0.0) self.frame = 0 self.framelimit = (14) self.lastframe = (self.framelimit + 14) self.colourmatrix = [[None]*self.cube.size]*self.cube.size for y in range(self.cube.size): for x in range(self.cube.size): self.colourmatrix[x][y] = cubehelper.random_color()
def tick(self): self.cube.clear() for axis in range(0,random.randint(1,3)): self.moveaxis(axis) self.cube.set_pixel((self.position[0],self.position[1],self.position[2]),cubehelper.random_color())
def reset(self): self.z = self.cube.size self.speed = random.uniform(1.0, 0.25) self.color = cubehelper.random_color()
def pick_color(self): if self.cube.color: return cubehelper.random_color() return (1.0, 1.0, 1.0)
def init(self): self.offset = 0.0 self.double_buffer = True self.n = random.choice([1, 2]) self.color = [cubehelper.random_color() for i in range(0, self.n)] return DT