def random1(self): a = utilcube.alle(0, 0, 0) while True: coordinates = utilcube.random_coordinates() color = utilcube.random_color() a[coordinates[0]][coordinates[1]][coordinates[2]][0] = color[0] a[coordinates[0]][coordinates[1]][coordinates[2]][1] = color[1] a[coordinates[0]][coordinates[1]][coordinates[2]][2] = color[2] spicube.schreiben(a) time.sleep(0.1) if self.ex: return "exit"
def full_color_change(self): grad = utilcube.get_grad_array() while True: for g in grad: r, g, b = utilcube.grad_to_rgb(g) a = utilcube.alle(r, g, b) spicube.schreiben(a) time.sleep(1) if self.ex: return "exit"
def random2(self): farben = np.arange(0, 360, 60) a = utilcube.alle(0, 0, 0) while True: for x, y, z in itertools.product(range(12), range(12), range(12)): grad = random.choice(farben) color = colorsys.hsv_to_rgb(grad / 360, 1.0, 1.0) color = np.asarray(color) color *= 255 a[x][y][z][0] = color[0] a[x][y][z][1] = color[1] a[x][y][z][2] = color[2] spicube.schreiben(a) time.sleep(0.0) if self.ex: return "exit"
def random3(self): a = utilcube.alle(0, 0, 0) list_coordinates = [] number = 200 for i in range(number): coordinates = utilcube.random_coordinates() color = utilcube.random_color() list_coordinates.append(coordinates) a[coordinates[0]][coordinates[1]][coordinates[2]][0] = color[0] a[coordinates[0]][coordinates[1]][coordinates[2]][1] = color[1] a[coordinates[0]][coordinates[1]][coordinates[2]][2] = color[2] spicube.schreiben(a) while True: for i in range(number): # alte koordinate holen und löschen, led aus coordinate = list_coordinates[i] a[coordinate[0]][coordinate[1]][coordinate[2]][0] = 0 a[coordinate[0]][coordinate[1]][coordinate[2]][1] = 0 a[coordinate[0]][coordinate[1]][coordinate[2]][2] = 0 # neue koordinate holen, in liste speichern, led setzen coordinate = utilcube.random_coordinates() list_coordinates[i] = coordinate color = utilcube.random_color() a[coordinate[0]][coordinate[1]][coordinate[2]][0] = color[0] a[coordinate[0]][coordinate[1]][coordinate[2]][1] = color[1] a[coordinate[0]][coordinate[1]][coordinate[2]][2] = color[2] spicube.schreiben(a) time.sleep(1) if self.ex: return "exit"
def show(self): a = utilcube.alle(0, 0, 0) # Blauer Himmel for x, y in itertools.product(range(12), range(12)): a[x][y][11][0] = 255 a[x][y][11][1] = 255 a[x][y][11][2] = 255 spicube.schreiben(a) # Liste mit Himmels-Koordinaten himmel_koor = [] for x, y in itertools.product(range(12), range(12)): himmel_koor.append((x, y)) np.random.shuffle(himmel_koor) for x, y in himmel_koor: time.sleep(0.5) for i in reversed(range(11)): a[x][y][i + 1][0] = 0 a[x][y][i + 1][1] = 0 a[x][y][i + 1][2] = 0 a[x][y][i][0] = 255 a[x][y][i][1] = 255 a[x][y][i][2] = 255 if i == 0: a[x][y][i][0] = 255 a[x][y][i][1] = 255 a[x][y][i][2] = 255 spicube.schreiben(a) time.sleep(0.05) # 0.01 if self.ex: return "exit"
def show(self): a = utilcube.alle(0,0,0) # start position x = 0 y = 0 z = 0 state = "rechts" delay = 0.05 count = 0 while True: if self.ex: return "exit" #print(count, x,y,z, state) while True: if self.ex: return "exit" if state == "rechts": if (self.gueltiges_feld(x,y,z)): self.belege_feld(x,y,z) a[x][y][z][0] = 255 spicube.schreiben(a) time.sleep(delay) if self.ex: return "exit" x += 1 break else: x -= 1 y += 1 state = "hoch" break if state == "hoch": if (self.gueltiges_feld(x,y,z)): self.belege_feld(x,y,z) a[x][y][z][0] = 255 spicube.schreiben(a) time.sleep(delay) if self.ex: return "exit" y += 1 break else: state = "links" y -= 1 x -= 1 break if state == "links": if (self.gueltiges_feld(x,y,z)): self.belege_feld(x,y,z) a[x][y][z][0] = 255 spicube.schreiben(a) time.sleep(delay) if self.ex: return "exit" x -= 1 break else: state = "runter" x += 1 y -= 1 break if state == "runter": if (self.gueltiges_feld(x,y,z)): self.belege_feld(x,y,z) a[x][y][z][0] = 255 spicube.schreiben(a) time.sleep(delay) if self.ex: return "exit" y -= 1 break else: state = "rechts" y += 1 x += 1 break count = np.count_nonzero(a) if count % 144 == 0: z += 1 x = 0 y = 0 state = "rechts"