Esempio n. 1
0
 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)
Esempio n. 2
0
 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
Esempio n. 3
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
Esempio n. 4
0
 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
Esempio n. 5
0
 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)
Esempio n. 6
0
 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
Esempio n. 7
0
    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)
Esempio n. 8
0
    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);
Esempio n. 9
0
 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
Esempio n. 10
0
    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
Esempio n. 11
0
 def init(self):
     self.phase = 0
     self.offset = -self.cube.size
     self.color = cubehelper.random_color()
     return 1.0 / self.cube.size
Esempio n. 12
0
 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
Esempio n. 13
0
 def set_colour(self, c=None):
     if c is None:
         c = cubehelper.random_color()
     self.colour = c
Esempio n. 14
0
 def restart(self):
     self.offset = 0
     self.corner = self.corners[random.randrange(0, 8)]
     self.filling_color = cubehelper.random_color(self.filling_color)
Esempio n. 15
0
 def reset(self):
     self.bitmap = [0] * len(self.pos)
     self.message = self.saved_message
     self.color = cubehelper.random_color()
Esempio n. 16
0
 def init(self):
     self.level = 0.0
     self.delta = 1.0/16
     self.color = cubehelper.random_color()
     return 1.0/16
Esempio n. 17
0
    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()
Esempio n. 18
0
 def init(self):
     self.phase = 0
     self.offset = -self.cube.size
     self.color = cubehelper.random_color()
     return 1.0 / self.cube.size
Esempio n. 19
0
 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())
Esempio n. 20
0
 def reset(self):
     self.z = self.cube.size
     self.speed = random.uniform(1.0, 0.25)
     self.color = cubehelper.random_color()
Esempio n. 21
0
 def pick_color(self):
     if self.cube.color:
         return cubehelper.random_color()
     return (1.0, 1.0, 1.0)
Esempio n. 22
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