def demo(screen, scene): # scenes = [Scene([MainView(screen, datacache)], -1, name="Main Screen"), # Scene([TimeView(screen, datacache, 0)], -1, name="P Screen"), # Scene([TimeView(screen, datacache, 1)], -1, name="B Screen"), # Scene([TimeView(screen, datacache, 2)], -1, name="L Screen") # ] effect2 = Stars(screen, screen.width) effects = [ Print(screen, BarChart(10, 40, [10, 10], char="=", gradient=[(20, Screen.COLOUR_GREEN), (30, Screen.COLOUR_YELLOW), (40, Screen.COLOUR_RED)]), x=13, y=1, transparent=False, speed=2) ] scenes2 = [Scene([MainView(screen, datacache)], -1, name="Main Screen")] scenes3 = [Scene([effect2], -1)] screen.play(scenes2, stop_on_resize=True, start_scene=scene, allow_int=True)
def demo(screen): effects = [ Cycle(screen, FigletText("NCBI FTP Searcher", font='big'), int(screen.height / 2 - 8)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def run(screen): scenes = [] centre = (screen.width // 2, screen.height // 2) # Intro effects = [ Stars(screen, (screen.width + screen.height) // 2, start_frame=0), Print( screen, FigletText( """I’m afraid sometimes you’ll play lonely games too, games you can’t win because you’ll play against you."""), x=centre[0] - 100, y=centre[1] - 20, clear=True, start_frame=0, stop_frame=200), Print(screen, Rainbow(screen, FigletText("Press <SPACE> to start")), x=centre[0] - 100, y=centre[1] - 20, clear=True, start_frame=200, stop_frame=2000), ] scenes.append(Scene(effects, -1)) # Scene 1, start the game side_panel = [ Print(screen, Box(screen.width // 5, screen.height, uni=screen.unicode_aware), 0, 0, start_frame=0), Print(screen, FigletText("Side", font="big"), x=0, y=1, clear=True, start_frame=0, stop_frame=100), ] effects = [ Print(screen, Box((screen.width // 5) * 4, screen.height, uni=screen.unicode_aware), 0, screen.width // 5, start_frame=0), ] final = side_panel + effects scenes.append(Scene(final, -1)) screen.refresh() # sleep(100) screen.play(scenes, stop_on_resize=True)
def test_stars_pattern(self): """ Check that Stars custom pattern value works. """ # Check that Stars randomly updates the Screen every frame. screen = MagicMock(spec=Screen, colours=8, unicode_aware=False) canvas = Canvas(screen, 10, 40, 0, 0) effect = Stars(canvas, 100, "TESTTESTTEST") effect.reset() my_buffer = [[(32, 7, 0, 0) for _ in range(40)] for _ in range(10)] for i in range(10): effect.update(i) self.assertTrue(self.check_canvas( canvas, my_buffer, lambda value: self.assertIn(chr(value[0]), " TES")))
def day1_1(screen): inputs = [ int(x) for x in open("/Users/ciaran.whyte/dev/aoc2020/day1/input.txt"). read().splitlines() ] for idx, num in enumerate(inputs): c_one = idx for idx_two, c_two in enumerate(inputs[idx:]): update_visual(screen, inputs, c_one, idx + idx_two) if c_two + num == 2020: # centre = (screen.width // 2, screen.height // 2) # screen.print_at(text=f"{num} + {c_two} == 2020", x=centre[0], y=centre[1], colour=0, bg=13) # screen.print_at(text=f"{num} * {c_two} == {num * c_two}", x=centre[0]+1, y=centre[0]+1, colour=3, bg=0) # screen.refresh() # screen.close() effects = [ Cycle(screen, FigletText(f"{num} + {c_two} == 2020", font='big'), int(screen.height / 2 - 8)), Cycle( screen, FigletText(f"{num} * {c_two} == {num * c_two}", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)]) time.sleep(5) return
def reset(self, old_scene=None, screen=None): effects = [ Stars(self._screen, (20)), self.intro_text(self.car_text, 0, x=22, y=10), self.intro_text(constants.river_scene_story_text, 40, x=12, y=35), ] for fx in effects: self.add_effect(fx)
def demo(screen): effects = [ Cycle(screen, FigletText("Dan is the best", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("", font='big'), int(screen.height / 2)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def demo(screen): 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) ] screen.play([Scene(effects, 500)])
def win_animation(screen): effects = [ Cycle(screen, FigletText("YOU", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("WON", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def WelcomeMsg(screen): effects = [ Cycle(screen, FigletText("ROBOCOP", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("cop without gun", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 20)], repeat=False)
def demo(screen): effects = [ Cycle(screen, FigletText("Twitter", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("Bot!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def demo(screen): effects = [ Cycle(screen, FigletText("SANDER", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("ROCKS!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def demo(screen): effects = [ Cycle(screen, FigletText("TABLE TENNIS", font='big'), screen.height // 2 - 8), Cycle(screen, FigletText("SCOREBOARD", font='big'), screen.height // 2 + 3), Stars(screen, (screen.width + screen.height) // 2) ] screen.play([Scene(effects, 500)])
def doit(screen): effects = [ Cycle(screen, FigletText("You", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("Won!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 5000)])
def display(screen): effects = [ Cycle(screen, FigletText("WELCOME TO", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("PYCON-NG 2019!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def title_screen_graphics(self, screen): effects = [ Cycle(screen, FigletText("Cat", font='univers'), screen.height // 2 - 8), Cycle(screen, FigletText("Quest", font='univers'), screen.height // 2 + 3), Stars(screen, (screen.width + screen.height) // 2) ] screen.play([Scene(effects, 66)], repeat=False)
def ascii_greeter(screen): effects = [ Cycle(screen, FigletText("StereoStrand", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("ROCKS!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 100)], repeat=False)
def demo(screen): effects = [ Cycle(screen, FigletText("HALFWAY", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("CROOKS", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def demo(screen): effects = [ Cycle(screen, FigletText("We4theRep0rt", font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("The best has yet to come", font='small'), int(screen.height / 2 + 3)), Stars(screen, 600) ] screen.play([Scene(effects, 500)])
def demo(screen=None, output1="", output2=""): effects = [ Print(screen, Rainbow(screen, FigletText("{}".format(str(output1)))), screen.height // 2 - 7), Print(screen, Rainbow(screen, FigletText("{}".format(str(output2)))), screen.height // 2), Stars(screen, (screen.width + screen.height) // 2) ] screen.play([Scene(effects, 500)])
def demo(screen=None, output1="", output2="", duration=50): effects = [ Print(screen, Rainbow(screen, FigletText("{}".format(str(output1)))), screen.height // 2 - 7), Print(screen, Rainbow(screen, FigletText("{}".format(str(output2)))), screen.height // 2), Stars(screen, (screen.width + screen.height) // 2) ] screen.play([Scene(effects, duration)], repeat=False)
def test_stars(self): """ Check that Stars works. """ # Check that Stars randomly updates the Screen every frame. screen = MagicMock(spec=Screen, colours=8) canvas = Canvas(screen, 10, 40, 0, 0) effect = Stars(canvas, 100) 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.assertTrue(self.check_canvas( canvas, buffer, lambda value: self.assertIn(chr(value[0]), " .+x*"))) # Check there is no stop frame by default. self.assertEqual(effect.stop_frame, 0)
def demo(screen): Test = "This is only a Test" effects = [ Cycle(screen, FigletText(Test, font='big'), int(screen.height / 2 - 8)), Cycle(screen, FigletText("Julie!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] screen.play([Scene(effects, 500)])
def demo(screen): effects = [ Cycle( screen, FigletText("NETWORKING", font='big'), screen.height // 2 - 8), Cycle( screen, FigletText("DOWN UNDER", font='big'), screen.height // 2 + 3), Stars(screen, (screen.width + screen.height) // 2) ] screen.play([Scene(effects, 500)])
def display(screen): effects = [ Cycle(screen, FigletText("Shanghai University", font='big'), screen.height // 2 - 10), Cycle(screen, FigletText("Edu-System", font='big'), screen.height // 2 - 1), Stars(screen, (screen.width + screen.height) // 2), Print(screen, SpeechBubble("Press 'space' to login."), screen.height // 2 + 10, attr=Screen.A_BOLD) ] screen.play([Scene(effects, 500)], repeat=False)
def demo(screen): effects = [ Cycle(screen, FigletText("50th anniversary of APOLLO 11", font='big'), screen.height // 2 - 8), Stars(screen, (screen.width + screen.height) // 2), RingFirework(screen, 10, 10, 50), StarFirework(screen, 40, 8, 50), RingFirework(screen, 70, 12, 50), RingFirework(screen, 100, 10, 50), StarFirework(screen, 130, 8, 50), RingFirework(screen, 160, 12, 50) ] screen.play([Scene(effects, 100)], ExplosionFlames(screen, 44, 20, 100))
def concur_labs(screen): effects = [ Cycle( screen, FigletText("LibraryPi", font='big'), int(screen.height / 2 - 8)), Cycle( screen, FigletText("ConcurLabs", font='small'), int(screen.height / 2 + 3)), Stars(screen, 100) ] screen.play([Scene(effects)], unhandled_input=stop_on_keypress)
def demo(screen): effects = [ Cycle( screen, FigletText("HELLO", font='big'), int(screen.height / 2 - 8)), Cycle( screen, FigletText("WORLD", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200), ] screen.play([Scene(effects, 500)])
def create_effect(screen): 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) ] return effects
def fireworks(screen): scenes = [] effects = [ Stars(screen, screen.width), Print(screen, SpeechBubble("Press space to see it again"), y=screen.height - 3, start_frame=300) ] for _ in range(20): fireworks = [ (PalmFirework, 25, 30), (PalmFirework, 25, 30), (StarFirework, 25, 35), (StarFirework, 25, 35), (StarFirework, 25, 35), (RingFirework, 20, 30), (SerpentFirework, 30, 35), ] firework, start, stop = choice(fireworks) effects.insert( 1, firework(screen, randint(0, screen.width), randint(screen.height // 8, screen.height * 3 // 4), randint(start, stop), start_frame=randint(0, 250))) effects.append( Print(screen, Rainbow(screen, FigletText("CONGRATULATIONS")), screen.height // 2 - 6, speed=1, start_frame=100)) effects.append( Print(screen, Rainbow(screen, FigletText("TO YOUR")), screen.height // 2 + 1, speed=1, start_frame=100)) effects.append( Print(screen, Rainbow(screen, FigletText("OPTIMAL SCHEDULE")), screen.height // 2 + 1, speed=1, start_frame=100)) scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True, repeat=False)
def demo(screen): effects = [ Cycle( screen, FigletText("ASCIIMATICS", font='big'), screen.height // 2 - 8), BannerText( screen, FigletText("ROCKS!", font='big'), screen.height // 2 + 3, Screen.COLOUR_CYAN, Screen.COLOUR_BLACK), Stars(screen, (screen.width + screen.height) // 2) ] screen.play([Scene(effects, 500)])
def splashScreen(screen): effects = [ Cycle( screen, FigletText("PASSMAN,", font='big'), int(screen.height / 2 - 8)), Cycle( screen, FigletText("MAN!", font='big'), int(screen.height / 2 + 3)), Stars(screen, 200) ] # play for 25 ms, don't repeat screen.play([Scene(effects, 25)], repeat=False)
def test_stars(self): """ Check that Stars works. """ # Check that Stars randomly updates the Screen every frame. screen = MagicMock(spec=Screen, colours=8, unicode_aware=False) canvas = Canvas(screen, 10, 40, 0, 0) effect = Stars(canvas, 100) 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.assertTrue(self.check_canvas( canvas, my_buffer, lambda value: self.assertIn(chr(value[0]), " .+x*"))) # 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))