def cube_visuals(): return generators.sequence([ generators.sequence([ scroll_past(Cube(SIZE, Colour.red()), Direction.UP), scroll_past(Cube(SIZE, Colour.green()), Direction.RIGHT), scroll_past(Cube(SIZE, Colour.blue()), Direction.FRONT), ]), generators.repeat(faces.faces(), 10), generators.repeat(edges.edges(), 10), text.text("BRIGHT", [Colour.red(), Colour.green(), Colour.blue()]), generators.fast( line_maps.line_to_cube( generators.sequence([ line.scroll_in(line.rainbow()), line.scroll_out(line.rainbow()), ]))), text.text("subtle", [ Colour((Colour.brightness // 8, 0, 0)), Colour((0, Colour.brightness // 8, 0)), Colour((0, 0, Colour.brightness // 8)) ]), generators.repeat(corners.corners(), 10), generators.frame_limit(spiral.spiral(), 100), generators.repeat(extend.extend(), 3), generators.frame_limit(generators.slow(layers.layers(), frames=4), 100), generators.frame_limit(wave.wave(), 100), generators.frame_limit(snakes.snakes(), 300), generators.frame_limit(matrix.matrix(), 300), generators.frame_limit(rope.rope(), 300), generators.repeat(fireworks.fireworks(), 10), generators.repeat(pins.pins(), 5), ])
def rotate(): cube = rainbow.make_colour_cube() return generators.sequence([ generators.repeat(rotate_cube(cube, Direction.UP), 5), generators.repeat(rotate_cube(cube, Direction.LEFT), 5), generators.repeat(rotate_cube(cube, Direction.FRONT), 5), ])
def marquee(text, colours): if type(colours) is not list: colours = [colours] text_characters = [ display_character(text[i], colours[i % len(colours)]) for i in range(len(text)) ] return generators.sequence( [display_character(" ", Colour.BLACK)] + text_characters + [display_character(" ", Colour.BLACK)], transition=functools.partial(grid_transitions.scroll, Direction.RIGHT))
def scroll_past(colours, dir=1): return generators.sequence([scroll_in(colours, dir=dir), single_frame(colours), scroll_out(colours, dir=dir)])
def scrolling_rainbow(num_leds = LEDS): return generators.sequence([ scroll_in(rainbow(num_leds = num_leds)), generators.repeat(cycle(rainbow(num_leds = num_leds)), 2), scroll_out(rainbow(num_leds = num_leds)), ])
def scroll_pixel(colour): cs = [colour] + [Colour.BLACK for i in range(LEDS - 1)] return generators.sequence([single_frame(cs), scroll_out(cs)])
def scroll_pixel(colour): cs = [colour] + [Colour.BLACK for i in range(LEDS - 1)] return generators.sequence([single_frame(cs), scroll_out(cs)]) if __name__ == "__main__": with Display() as d: # For testing the LEDs: #generators.generate(d, generators.sequence([ # scroll_pixel(Colour.red()), # scroll_pixel(Colour.green()), # scroll_pixel(Colour.blue()), #])) generators.generate(d, generators.shuffle([ mirror(reverse(binary_count(LEDS // 2))), knight_rider(10), scroll_past([Colour.red() for i in range(LEDS)]), scroll_past([Colour.green() for i in range(LEDS)]), scroll_past([Colour.blue() for i in range(LEDS)]), scroll_past([Colour.cyan() for i in range(LEDS)], dir=-1), scroll_past([Colour.magenta() for i in range(LEDS)], dir=-1), scroll_past([Colour.yellow() for i in range(LEDS)], dir=-1), generators.sequence([ scroll_in(rainbow()), generators.repeat(cycle(rainbow()), 5), generators.repeat(cycle(rainbow(), dir=-1), 5), scroll_out(rainbow(), dir=-1), ]), ]))
def scroll_past(cube, direction): return generators.sequence([ scroll_in(cube, direction), single_frame(cube), scroll_out(cube, direction) ])
return generators.sequence([ scroll_in(cube, direction), single_frame(cube), scroll_out(cube, direction) ]) def combine_cubes(cube_a, cube_b): c = cube_a.copy() for x in range(cube_a.size): for y in range(cube_a.size): for z in range(cube_a.size): p = Pos(x, y, z) if c.get(p) == Colour.BLACK: c.set(p, cube_b.get(p)) return c if __name__ == "__main__": with Display() as d: generators.generate(d, generators.sequence([ scroll_past(Cube(SIZE, Colour.red()), Direction.UP), scroll_past(Cube(SIZE, Colour.green()), Direction.RIGHT), scroll_past(Cube(SIZE, Colour.blue()), Direction.FRONT), ]), delay=0.5)
from display import * import generators def single_frame(colours): while True: yield colours yield True if __name__ == "__main__": with Display() as d: generators.generate(d, generators.sequence([ single_frame([Colour.red()]), single_frame([Colour.green()]), single_frame([Colour.blue()]) ]), delay=0.5)
for slice_index in range(SIZE): pos = ([(low + i, low) for i in range(length)] + [(high, low + i) for i in range(length)] + [(high - i, high) for i in range(length)] + [(low, high - i) for i in range(length)]) if length == 0: pos = [(low, low)] real_slice_index = slice_index if (layer % 2) == 0 else SIZE - 1 - slice_index for i in range(len(pos)): cube.set(convert_face_coordinates(Direction.FRONT, pos[i], real_slice_index), colours[i]) colours = colours[len(pos):] return cube def line_to_cube(line_generator, cube_transform = control_order): for val in line_generator: if type(val) is bool: yield val else: yield cube_transform(val) if __name__ == "__main__": with Display() as d: generators.generate(d, generators.transform(line_to_cube(generators.sequence([ line.scroll_in(line.rainbow()), generators.repeat(line.cycle(line.rainbow()), 2), line.scroll_out(line.rainbow()), ]), spiral), functools.partial(rotate.rotate, Direction.LEFT, 1)))
def main(): with Display() as d: generators.generate( d, generators.sequence( [flatten()], transition=transitions.random_scroll_transition))