def demo(screen): scenes = [] cell1 = Rainbow(screen, RotatedDuplicate(screen.width // 2, max(screen.width // 2, screen.height), FigletText("ASCII" if screen.width < 80 else "ASCII rules", font="banner", width=screen.width // 2))) cell2 = "" size = int(sqrt(screen.height ** 2 + screen.width ** 2 // 4)) for _ in range(size): for x in range(size): c = x * screen.colours // size cell2 += "${%d,2,%d}:" % (c, c) cell2 += "\n" for i in range(8): scenes.append( Scene([Print(screen, Kaleidoscope(screen.height, screen.width, cell1, i), 0, speed=1, transparent=False), Print(screen, FigletText(str(i)), screen.height - 6, x=screen.width - 8, speed=1)], duration=360)) scenes.append( Scene([Print(screen, Kaleidoscope(screen.height, screen.width, StaticRenderer([cell2]), i), 0, speed=1, transparent=False)], duration=360)) screen.play(scenes, stop_on_resize=True)
def demo(screen): effects = [ Print(screen, Kaleidoscope(screen.height, screen.width, screen.colours, 8), 0, speed=1, transparent=False), ] screen.play([Scene(effects)], stop_on_resize=True)
def test_kaleidoscope(self): """ Check that the Kaleidoscope renderer works. """ # Check basic content of the renderer renderer = Kaleidoscope(5, 10, StaticRenderer(["# # #\n" * 5]), 3) # Check several renderings for _ in range(180): output = renderer.rendered_text for char in "\n".join(output[0]): self.assertIn(char, ' #\n') # Check dimensions self.assertEqual(renderer.max_height, 5) self.assertEqual(renderer.max_width, 10)
def demo(screen): scenes = [] cell = " " size = int(sqrt(screen.height**2 + screen.width**2 // 4)) for _ in range(size): for x in range(size): c = x * screen.colours // size cell += "${%d,2,%d}:" % (c, c) cell += "\n" scenes.append( Scene([ Print(screen, Kaleidoscope(screen.height, screen.width, StaticRenderer([cell]), 3), 0, speed=1, transparent=False) ], duration=1000)) screen.play(scenes, stop_on_resize=False, allow_int=True)