def singleton(screen, scene, tbapi, serial): scenes = [ Scene([Matrix(screen), MainMenu(screen, settings, tbapi, serial)], -1, name="Main"), ] screen.play(scenes, stop_on_resize=False, start_scene=scene)
def test_matrix(self): """ Check that the Matrix works. """ # Check that Matrix randomly updates the Screen every other frame. screen = MagicMock(spec=Screen, colours=8, unicode_aware=False) canvas = Canvas(screen, 10, 40, 0, 0) effect = Matrix(canvas) effect.reset() self.assert_blank(canvas) my_buffer = [[(32, 7, 0, 0) for _ in range(40)] for _ in range(10)] for i in range(10): effect.update(i) self.assertEqual(self.check_canvas( canvas, my_buffer, lambda value: self.assertTrue(value[0] == 32 or value[1] == 2)), i % 2 == 0) # Check there is no stop frame by default. self.assertEqual(effect.stop_frame, 0) # This effect should ignore events. event = object() self.assertEqual(event, effect.process_event(event))
def test_matrix(self): """ Check that the Matrix works. """ # Check that Matrix randomly updates the Screen every other frame. screen = MagicMock(spec=Screen, colours=8) canvas = Canvas(screen, 10, 40, 0, 0) effect = Matrix(canvas) effect.reset() self.assert_blank(canvas) buffer = [[(32, 7, 0, 0) for _ in range(40)] for _ in range(10)] for i in range(10): effect.update(i) self.assertEqual(self.check_canvas( canvas, buffer, lambda value: self.assertTrue(value[0] == 32 or value[1] == 2)), i % 2 == 0) # Check there is no stop frame by default. self.assertEqual(effect.stop_frame, 0)
def _credits(screen): scenes = [] text = Figlet(font="banner", width=200).renderText("ATK") width = max([len(x) for x in text.split("\n")]) effects = [ Matrix(screen, stop_frame=200), Mirage(screen, FigletText("ATK"), screen.height // 2 - 3, Screen.COLOUR_GREEN, start_frame=100, stop_frame=200), Wipe(screen, start_frame=150), Cycle(screen, FigletText("ATK"), screen.height // 2 - 3, start_frame=200) ] scenes.append(Scene(effects, 250, clear=False)) screen.play(scenes, stop_on_resize=True, repeat=False)
def test_matrix(self): """ Check that the Matrix works. """ # Check that Matrix randomly updates the Screen every other frame. screen = MagicMock(spec=Screen, colours=8) canvas = Canvas(screen, 10, 40, 0, 0) effect = Matrix(canvas) effect.reset() self.assert_blank(canvas) buffer = [[(32, 7, 0, 0) for _ in range(40)] for _ in range(10)] for i in range(10): effect.update(i) self.assertEqual( self.check_canvas( canvas, buffer, lambda value: self.assertTrue(value[ 0] == 32 or value[1] == 2)), i % 2 == 0) # Check there is no stop frame by default. self.assertEqual(effect.stop_frame, 0)
def demo(screen): scenes = [] if screen.width != 132 or screen.height != 24: pass # effects = [ # Print(screen, FigletText("Resize to 132x24"), # y=screen.height//2-3), # ] if True: effects = [ Print( screen, BarChart(20, 40, [fn, fn, fn2], char="d", gradient=[(20, Screen.COLOUR_GREEN), (30, Screen.COLOUR_YELLOW), (40, Screen.COLOUR_RED)]), x=1, y=1, transparent=False, speed=2, delete_count=50, ), Matrix(screen, delete_count=50) # Clock(screen, x=10, y=10, r=10) # Print(screen, # BarChart( # 13, 60, # [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)], # colour=Screen.COLOUR_GREEN, # axes=BarChart.BOTH, # scale=2.0), # x=68, y=1, transparent=False, speed=2), # Print(screen, # BarChart( # 7, 60, [lambda: time.time() * 10 % 101], # gradient=[ # (33, Screen.COLOUR_RED, Screen.COLOUR_RED), # (66, Screen.COLOUR_YELLOW, Screen.COLOUR_YELLOW), # (100, Screen.COLOUR_WHITE, Screen.COLOUR_WHITE), # ] if screen.colours < 256 else [ # (10, 234, 234), (20, 236, 236), (30, 238, 238), # (40, 240, 240), (50, 242, 242), (60, 244, 244), # (70, 246, 246), (80, 248, 248), (90, 250, 250), # (100, 252, 252) # ], # char=">", # scale=100.0, # labels=True, # axes=BarChart.X_AXIS), # x=68, y=16, transparent=False, speed=2), # Print(screen, # BarChart( # 10, 60, # [wv(1), wv(2), wv(3), wv(4), wv(5), wv(7), wv(8), wv(9)], # colour=[c for c in range(1, 8)], # bg=[c for c in range(1, 8)], # scale=2.0, # axes=BarChart.X_AXIS, # intervals=0.5, # labels=True, # border=False), # x=3, y=13, transparent=False, speed=2) ] # if time.time() - start < delta: scenes.append(Scene(effects)) screen.play(scenes, stop_on_resize=True)
def _credits(screen): scenes = [] centre = (screen.width // 2, screen.height // 2) curve_path = [] for i in range(0, 11): curve_path.append( (centre[0] + (screen.width / 3 * math.sin(i * math.pi / 5)), centre[1] - (screen.height / 3 * math.cos(i * math.pi / 5)))) path = Path() path.jump_to(-20, centre[1] - screen.height // 3) path.move_straight_to(centre[0], centre[1] - screen.height // 3, 10), path.wait(30) path.move_round_to(curve_path, 80) path.wait(30) path.move_straight_to(7, 4, 10) path.wait(300) effects = [ Sam(screen, path), Print(screen, SpeechBubble("WELCOME TO ASCIIMATICS", "L"), x=centre[0] + 12, y=(centre[1] - screen.height // 3) - 4, colour=Screen.COLOUR_CYAN, clear=True, start_frame=20, stop_frame=50), Print(screen, SpeechBubble("Wheeeeeee!"), y=centre[1], colour=Screen.COLOUR_CYAN, clear=True, start_frame=100, stop_frame=250), Print(screen, SpeechBubble("A world of possibilities awaits you...", "L"), x=18, y=0, colour=Screen.COLOUR_CYAN, clear=True, start_frame=350, stop_frame=400), Print(screen, ImageFile("globe.gif", colours=screen.colours), 0, start_frame=400), ] scenes.append(Scene(effects, 600)) effects = [ Matrix(screen, stop_frame=200), Mirage(screen, FigletText("Asciimatics"), screen.height // 2 - 3, Screen.COLOUR_GREEN, start_frame=100, stop_frame=200), Wipe(screen, start_frame=150), Cycle(screen, FigletText("Asciimatics"), screen.height // 2 - 3, start_frame=200) ] scenes.append(Scene(effects, 250, clear=False)) effects = [ BannerText( screen, Rainbow( screen, FigletText("Reliving the 80s in glorious ASCII text...", font='slant')), screen.height // 2 - 3, Screen.COLOUR_GREEN) ] scenes.append(Scene(effects)) effects = [ Mirage(screen, FigletText("Conceived and"), screen.height, Screen.COLOUR_GREEN), Mirage(screen, FigletText("written by:"), screen.height + 8, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Peter Brittain"), screen.height + 16, Screen.COLOUR_GREEN), Scroll(screen, 3) ] scenes.append(Scene(effects, (screen.height + 24) * 3)) effects = [ Cycle(screen, FigletText("ASCIIMATICS", font='big'), screen.height // 2 - 8), Cycle(screen, FigletText("ROCKS!", font='big'), screen.height // 2 + 3), Stars(screen, (screen.width + screen.height) // 2) ] scenes.append(Scene(effects, 200)) screen.play(scenes, stop_on_resize=True)
def _matrix(screen): return [Matrix(screen, stop_frame=200)]
def _credits(screen): scenes = [] text = Figlet(font="banner", width=200).renderText("ASCIIMATICS") width = max([len(x) for x in text.split("\n")]) effects = [ Print(screen, Fire(screen.height, 80, text, 0.4, 40, screen.colours), 0, speed=1, transparent=False), Print(screen, FigletText("ASCIIMATICS", "banner"), screen.height - 9, x=(screen.width - width) // 2 + 1, colour=Screen.COLOUR_BLACK, bg=Screen.COLOUR_BLACK, speed=1), Print(screen, FigletText("ASCIIMATICS", "banner"), screen.height - 9, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1), ] scenes.append(Scene(effects, 100)) effects = [ Matrix(screen, stop_frame=200), Mirage(screen, FigletText("Asciimatics"), screen.height // 2 - 3, Screen.COLOUR_GREEN, start_frame=100, stop_frame=200), Wipe(screen, start_frame=150), Cycle(screen, FigletText("Asciimatics"), screen.height // 2 - 3, start_frame=200) ] scenes.append(Scene(effects, 250, clear=False)) effects = [ BannerText( screen, Rainbow( screen, FigletText("Reliving the 80s in glorious ASCII text...", font='slant')), screen.height // 2 - 3, Screen.COLOUR_GREEN) ] scenes.append(Scene(effects)) effects = [ Mirage(screen, FigletText("Conceived and"), screen.height, Screen.COLOUR_GREEN), Mirage(screen, FigletText("written by:"), screen.height + 8, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Peter Brittain"), screen.height + 16, Screen.COLOUR_GREEN), Scroll(screen, 3) ] scenes.append(Scene(effects, (screen.height + 24) * 3)) effects = [ Mirage(screen, FigletText("With help from:"), screen.height, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Cory Benfield"), screen.height + 8, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Bryce Guinta"), screen.height + 16, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Aman Orazaev"), screen.height + 24, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Daniel Kerr"), screen.height + 32, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Dylan Janeke"), screen.height + 40, Screen.COLOUR_GREEN), Scroll(screen, 3) ] scenes.append(Scene(effects, (screen.height + 48) * 3)) effects = [ Cycle(screen, FigletText("ASCIIMATICS", font='big'), screen.height // 2 - 8, stop_frame=100), Cycle(screen, FigletText("ROCKS!", font='big'), screen.height // 2 + 3, stop_frame=100), Stars(screen, (screen.width + screen.height) // 2, stop_frame=100), DropScreen(screen, 100, start_frame=100) ] scenes.append(Scene(effects, 200)) effects = [ Print(screen, SpeechBubble("Press 'X' to exit."), screen.height // 2 - 1, attr=Screen.A_BOLD) ] scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True)
def matrix(screen: Screen) -> List[Matrix]: return [Matrix(screen, stop_frame=200)]
def _credits(screen): scenes = [] effects = [ Matrix(screen, stop_frame=200), Print(screen, FigletText("Catch Me", "banner3"), screen.height - 31, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=50, stop_frame=200), Print(screen, FigletText("(On Time)", "banner3"), screen.height - 21, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=75, stop_frame=200), Print(screen, FigletText("If You Can", "banner3"), screen.height - 11, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=100, stop_frame=200) ] scenes.append(Scene(effects, 250, clear=False)) effects = [ Background(screen, bg=Screen.COLOUR_BLACK), Print(screen, FigletText("Understanding the", "banner"), screen.height - 31, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=0, stop_frame=200), Print(screen, FigletText("Effectiveness of", "banner"), screen.height - 21, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=25, stop_frame=200), Print(screen, FigletText("Twitter URL Blacklist", "banner"), screen.height - 11, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=50, stop_frame=200) ] scenes.append(Scene(effects, 250, clear=False)) effects = [ Background(screen, bg=Screen.COLOUR_BLACK), Print(screen, FigletText("Authors:", "banner"), screen.height - 21, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=0, stop_frame=50, clear=1), Print(screen, FigletText("Simon Bell", "banner"), screen.height - 21, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=50, stop_frame=100, clear=1), Print(screen, FigletText("Lorenzo Cavallaro", "banner"), screen.height - 21, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, clear=1, start_frame=100, stop_frame=150), Print(screen, FigletText("Kenny Paterson", "banner"), screen.height - 21, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1, start_frame=150, stop_frame=200), ] scenes.append(Scene(effects)) effects = [ Background(screen, bg=Screen.COLOUR_BLACK), BannerText( screen, FigletText("Live measurement experiments in progress", font='banner3', width=400), #screen.height // 2 - 3, screen.height - 21, Screen.COLOUR_GREEN) ] scenes.append(Scene(effects)) screen.play(scenes, stop_on_resize=True)
def _credits(screen): scenes = [] text = Figlet(font="banner", width=200).renderText("ASCIIMATICS") width = max([len(x) for x in text.split("\n")]) effects = [ Print(screen, Fire(screen.height, 80, text, 0.4, 40, screen.colours), 0, speed=1, transparent=False), Print(screen, FigletText("ASCIIMATICS", "banner"), screen.height - 9, x=(screen.width - width) // 2 + 1, colour=Screen.COLOUR_BLACK, bg=Screen.COLOUR_BLACK, speed=1), Print(screen, FigletText("ASCIIMATICS", "banner"), screen.height - 9, colour=Screen.COLOUR_WHITE, bg=Screen.COLOUR_WHITE, speed=1), ] scenes.append(Scene(effects, 100)) effects = [ Matrix(screen, stop_frame=200), Mirage(screen, FigletText("Asciimatics"), screen.height // 2 - 3, Screen.COLOUR_GREEN, start_frame=100, stop_frame=200), Wipe(screen, start_frame=150), Cycle(screen, FigletText("Asciimatics"), screen.height // 2 - 3, start_frame=200) ] scenes.append(Scene(effects, 250, clear=False)) effects = [ BannerText( screen, Rainbow( screen, FigletText("Reliving the 80s in glorious ASCII text...", font='slant')), screen.height // 2 - 3, Screen.COLOUR_GREEN) ] scenes.append(Scene(effects)) effects = [ Scroll(screen, 3), Mirage(screen, FigletText("Conceived and"), screen.height, Screen.COLOUR_GREEN), Mirage(screen, FigletText("written by:"), screen.height + 8, Screen.COLOUR_GREEN), Mirage(screen, FigletText("Peter Brittain"), screen.height + 16, Screen.COLOUR_GREEN) ] scenes.append(Scene(effects, (screen.height + 24) * 3)) colours = [ Screen.COLOUR_RED, Screen.COLOUR_GREEN, ] contributors = [ "Cory Benfield", "Bryce Guinta", "Aman Orazaev", "Daniel Kerr", "Dylan Janeke", "ianadeem", "Scott Mudge", "Luke Murphy", "mronkain", "Dougal Sutherland", "Kirtan Sakariya", "Jesse Lieberg", "Erik Doffagne", "Noah Ginsburg", "Davidy22", "Christopher Trudeau", "Beniamin Kalinowski" ] effects = [ Scroll(screen, 3), Mirage( screen, FigletText("With help from:"), screen.height, Screen.COLOUR_GREEN, ) ] pos = 8 for i, name in enumerate(contributors): effects.append( Mirage( screen, FigletText(name), screen.height + pos, colours[i % len(colours)], )) pos += 8 scenes.append(Scene(effects, (screen.height + pos) * 3)) effects = [ Cycle(screen, FigletText("ASCIIMATICS", font='big'), screen.height // 2 - 8, stop_frame=100), Cycle(screen, FigletText("ROCKS!", font='big'), screen.height // 2 + 3, stop_frame=100), Stars(screen, (screen.width + screen.height) // 2, stop_frame=100), DropScreen(screen, 200, start_frame=100) ] scenes.append(Scene(effects, 300)) effects = [ Print(screen, SpeechBubble("Press 'X' to exit."), screen.height // 2 - 1, attr=Screen.A_BOLD) ] scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True)