def shift_right(self): new_map = [] for i in range(0, self.height): line = [pixel(0, 0, 0)] + self.pixel_map[(self.width*i):(self.width*(i+1))-1] new_map += line self.pixel_map = new_map
def shift_left(self): new_map = [] for i in range(0, self.height): line = self.pixel_map[(self.width*i)+1:(self.width*(i+1))] + [pixel(0, 0, 0)] new_map += line self.pixel_map = new_map
def rand_pixel(): return pixel(random.randint(-MAX, MAX), random.randint(-MAX, MAX), random.randint(-MAX, MAX))
def safe_get_pixel(line, size, index): if index < 0 or index >= size: return pixel(0, 0, 0) return line[index]
def set_pixel(self, x, y, red, green, blue): index = (y * self.width) + x self.pixel_map[index] = pixel(red, green, blue)
def __init__(self, width, height): self.width = width self.height = height self.pixel_map = [ pixel(0, 0, 0) for i in range( width * height ) ] self.animations = []
def shift_down(self): new_map = [pixel(0, 0, 0) for i in xrange(self.width)] new_map += self.pixel_map[:self.width*(self.height-1)] self.pixel_map = new_map