def demo(screen): scenes = [] centre = (screen.width // 2, screen.height // 2) podium = (8, 5) # Scene 1. path = Path() path.jump_to(-20, centre[1]) path.move_straight_to(centre[0], centre[1], 10) path.wait(30) path.move_straight_to(podium[0], podium[1], 10) path.wait(100) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "Secure TLS Deployment with LURK \n" +\ "-- Example: RSA Authentication --", centre, 30), ] scenes.append(Scene(effects)) # Scene 2 T = 0 path = Path() path.jump_to(podium[0], podium[1]) effects = [Arrow(screen, path, colour=Screen.COLOUR_GREEN)] Y = 8 speak = "In practice the line between Untrusted and " +\ "Trusted Domain does not exist..." labels = ["Untrusted Domain", "Trusted Domain"] colors = [Screen.COLOUR_RED, Screen.COLOUR_GREEN] effects += [_speak(screen, speak, podium, T)] effects += _background_display( screen, start=T, stop=T + TIC_SPEAK, labels=labels,\ colors=colors, y=Y, mode="header_plain") T += TIC_SPEAK speak = "Instead there is a continuum with Untrusted, \n" +\ "Exposed and Trusted Domain... " labels = ["Untrusted Domain", "Exposed Domain", "Trusted Domain"] colors = [ Screen.COLOUR_RED, Screen.COLOUR_YELLOW, \ Screen.COLOUR_GREEN ] effects += [_speak(screen, speak, podium, T)] effects += _background_display( screen, start=T, stop=T + 3 * TIC_SPEAK, labels=labels,\ colors=colors, y=Y, mode="header_plain") T += TIC_SPEAK speak = "For CDN: \n"+\ " * Untrusted Domain == Internet, \n" + \ " * Exposed Domain == delegated CDN, \n" +\ " * Trusted Domain == Your CDN... " effects += [_speak(screen, speak, podium, T)] T += TIC_SPEAK speak = "For vRAN: \n" +\ " * Untrusted Domain == Data Center, \n" +\ " * Exposed Domain == vRAN Software, \n" +\ " * Trusted Domain == Trusted Execution Environment..." effects += [_speak(screen, speak, podium, T)] T += TIC_SPEAK speak = "This can be extended to any case where TLS is used..." labels = ["TLS Client", "TLS Server", "Key Server"] effects += [_speak(screen, speak, podium, T)] effects += _background_display( screen, start=T, stop=END_OF_DEMO, labels=labels,\ colors=colors, y=Y, mode="header_plain") T += TIC_SPEAK Y += 2 speak = "A TLS Client terminates the session to the Exposed Environment" msg = "ClientHello \n" +\ " server_version \n" +\ " client_random \n" +\ " cipher_suite \n" +\ " TLS_RSA_*, ...\n" +\ "-------->" effects += move_h(screen, msg, Y, 'tls_clt', T) effects += [_speak(screen, speak, podium, T)] speak = "The TLS Server chose RSA authentication proposed by the \n" +\ "TLS Client " effects.append(_speak(screen, speak, podium, T + TIC_SPEAK)) T += max(TIC_MESSAGE, 2 * TIC_SPEAK) Y += msg.count('\n') + 1 speak = "The TLS Server knows RSA Authentication involves \n" +\ "interactions with the Key Server and obfuscates the \n" +\ "server_random to provide perfect forward secrecy. " effects.append(_speak(screen, speak, podium, T)) T += TIC_SPEAK speak = "The TLS Server: \n" +\ " - 1) Generates a server_random \n" +\ " - 2) Obfuscates the server_random \n" +\ " - 3) Sends the obfuscated value to the TLS Client \n" +\ " - 4) Sends the non obfuscated value to the Key Server" effects.append(_speak(screen, speak, podium, T)) txt = "LURK server_random: " txt_value = " gmt_unix_time \n" +\ " random " kwargs = { "colour" : Screen.COLOUR_YELLOW, "attr" : Screen.A_BOLD, \ "bg" : Screen.COLOUR_BLACK, "clear" : True, 'transparent' : True,\ 'x' : int( 1.1 * int(screen.width / 3 ) ), 'start_frame' : T, \ 'stop_frame' : END_OF_DEMO} y = Y - 2 # moving up to two lines the text args = [screen, s2r(txt), y] effects += [Print(*args, **kwargs)] kwargs['colour'] = Screen.COLOUR_RED args = [screen, s2r(txt_value), y + 1] effects += [Print(*args, **kwargs)] y += txt.count('\n') + 1 + txt_value.count('\n') txt = " Obfuscated TLS server_random: " txt_value= " gmt_unix_time \n" +\ " random " kwargs = { "colour" : Screen.COLOUR_YELLOW, "attr" : Screen.A_BOLD, \ "bg" : Screen.COLOUR_BLACK, "clear" : True, 'transparent' : True,\ 'x' : int( 1.1 * int(screen.width / 3 ) ), 'start_frame' : T, \ 'stop_frame' : END_OF_DEMO} args = [screen, s2r(txt), y] effects += [Print(*args, **kwargs)] kwargs['colour'] = Screen.COLOUR_WHITE args = [screen, s2r(txt_value), y + 1] effects += [Print(*args, **kwargs)] T += TIC_SPEAK speak = "The TLS Server responds with a ServerHello \n" +\ "That includes the obfuscated server_random " msg = "ServerHello \n" +\ " tls_version \n" +\ " server_random (TLS) \n" +\ " Cipher_suite=TLS_RSA \n" +\ "Certificate \n" +\ " RSA Public Key \n" +\ "ServerHelloDone \n" +\ "<-------- " effects += move_h(screen, msg, Y, 'tls_srv', T) effects += [_speak(screen, speak, podium, T)] T += max(TIC_MESSAGE, TIC_SPEAK) Y += msg.count('\n') + 1 speak = "The TLS Client sends a ClientKeyExchange \n" +\ "with the encrypted premaster " msg = "ClientKeyExchange \n" +\ " encrypted_premaster \n" +\ "-------->" effects += move_h(screen, msg, Y, 'tls_clt', T) effects += [_speak(screen, speak, podium, T)] T += max(TIC_MESSAGE, TIC_SPEAK) Y += msg.count('\n') + 1 speak = "Upon receiving the ClientKeyExchange, the \n" +\ "TLS Server initiates a LURK exchange with \n" +\ "the Key Server to: \n" +\ " - 1) Decyrpte the encrypted_premaster \n" +\ " - 2) Generate the master_secret " msg = "RSAMasterRequest \n" +\ " key_id \n" +\ " key_id_type \n" +\ " key_id \n" +\ " freshness_funct \n" +\ " client_random \n" +\ " gmt_unix_time \n" +\ " random = \n" +\ " server_random \n" +\ " gmt_unix_time \n" +\ " random = \n" +\ " encrypted_premaster\n" +\ "--------> " effects.append(_speak(screen, speak, podium, T)) effects += move_h(screen, msg, Y, 'lurk_clt', T) T += max(TIC_MESSAGE, TIC_SPEAK) Y += msg.count('\n') + 1 speak = "The Key Server : \n" +\ " - 1) Decrypts the encrypted_premaster \n" +\ " - 2) Generates the master secret " msg = "RSAMasterResponse\n" +\ " master \n" +\ "<-------- " effects.append(_speak(screen, speak, podium, T)) effects += move_h(screen, msg, Y, 'lurk_srv', T) T += max(TIC_MESSAGE, TIC_SPEAK) Y += msg.count('\n') + 1 speak = "With the master_secret, the TLS Server finalizes \n" +\ "the authenticated TLS Key Exchange. \n" +\ " \n" +\ "The TLS Server has not accessed the private key !" msg = "[ChangeCipherSpec] \n" +\ "Finishedit \n" +\ "--------> " effects += [_speak(screen, speak, podium, T)] effects += move_h(screen, msg, Y, 'tls_clt', T) T += max(TIC_MESSAGE, TIC_SPEAK) Y += msg.count('\n') + 1 msg = "[ChangeCipherSpec] \n" +\ " Finished \n" +\ "<-------- " effects += move_h(screen, msg, Y, 'tls_srv', T) T += max(TIC_SPEAK, TIC_SPEAK) Y += msg.count('\n') + 1 txt = "Application Data <-------> Application Data" kwargs = { "colour" : Screen.COLOUR_WHITE, "attr" : Screen.A_BOLD, \ "bg" : Screen.COLOUR_BLACK, "clear" : True, 'transparent' : True, \ 'x' : int( screen.width / 3 * ( 0.1 + 1 / 2) - len( txt ) / 2 ), \ 'start_frame' : T, 'stop_frame' : END_OF_DEMO } args = [screen, s2r(txt), Y] effects.append(Print(*args, **kwargs)) T += TIC_SPEAK Y += txt.count('\n') + 1 scenes.append(Scene(effects, duration=20000, clear=True)) #scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True)
def kitty(screen, scene): scenes = [] effects = [ ProfileFrame(screen), ] scenes.append(Scene(effects, -1, name='Main')) # scene cell = ColourImageFile(screen, 'img/4.jpg', screen.height) effects = [ RandomNoise(screen, signal=cell), Print(screen, Rainbow(screen, FigletText('Kitty', font='banner')), screen.height - 6, start_frame=200, bg=0), Print(screen, Rainbow(screen, FigletText('Kitty', font='banner')), screen.height - 6, start_frame=200, bg=0) ] scenes.append(Scene(effects, 380, name='Begin')) # scene effects = [ShootScreen(screen, screen.width // 2, screen.height // 2, 100)] scenes.append(Scene(effects, 60, clear=False)) #scene centre = ((screen.width // 2) - 20, (screen.height // 2) - 3) podium = (8, 5) path = Path() path.jump_to(-20, centre[1]) path.move_straight_to(centre[0], centre[1], 10) path.wait(30) path.move_straight_to(podium[0], podium[1], 10) path.wait(180) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), Snow(screen), Rain(screen, 340), Print(screen, StaticRenderer(images=tree), screen.height - 15, screen.width - 15, colour=Screen.COLOUR_GREEN), _speak( screen, u'This program write for the girl that i like, hope she will be happy!', centre, 30), _speak(screen, u'I like her at the first sight when i met her last year.', podium, 110), _speak( screen, u'I really like to chat with her, but afraid that she will be boring. ', podium, 180), Cycle(screen, Rainbow(screen, FigletText('Lovely', 'banner')), screen.height // 2 - 6, start_frame=220), Cycle(screen, Rainbow(screen, FigletText('Kitty', 'banner')), screen.height // 2 + 1, start_frame=220) ] scenes.append(Scene(effects, duration=340)) #scene cell = ColourImageFile(screen, 'img/10.jpg', screen.height, uni=screen.unicode_aware, dither=screen.unicode_aware) effects = [ Wipe(screen), Print(screen, cell, 0), Stars(screen, screen.height + screen.width) ] # for _ in range(20): # effects.append( # Explosion(screen, randint(0, screen.width), randint(screen.height//8, screen.height*3//4), randint(20, 150) ) # ) scenes.append(Scene(effects, 150, clear=False)) #scene cell = ColourImageFile(screen, 'img/3.jpg', screen.height, uni=screen.unicode_aware, dither=screen.unicode_aware) effects = [ DropScreen(screen, 100), BannerText(screen, cell, 0, Screen.COLOUR_YELLOW), Snow(screen) ] for _ in range(120): fireworks = [(PalmFirework, randint(25, 35)), (RingFirework, randint(25, 30)), (StarFirework, randint(30, 35)), (SerpentFirework, randint(28, 35))] firework, lifetime = choice(fireworks) effects.append( firework(screen, randint(0, screen.width), randint(screen.height // 8, screen.height * 3 // 4), lifetime, start_frame=randint(20, 250))) scenes.append(Scene(effects, 280, clear=False)) #scene cell = ColourImageFile(screen, 'img/1.jpg', screen.height, uni=screen.unicode_aware, dither=screen.unicode_aware) effects = [ Print(screen, cell, 0, speed=1), Scroll(screen, rate=10), Rain(screen, 200) ] scenes.append(Scene(effects, 180)) #scene text = Figlet(font="banner", width=200).renderText("Pretty Girl") 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), Print(screen, FigletText("Pretty Girl", 'banner'), screen.height - 9, x=(screen.width - width) // 2 + 1, colour=0, bg=0, speed=1), Print(screen, FigletText("Pretty Girl", 'banner'), screen.height - 9, x=(screen.width - width) // 2 + 1, colour=7, bg=7, speed=1) ] scenes.append(Scene(effects, 80)) #scene effects = [ Print(screen, Plasma(screen.height, screen.width, screen.colours), 0, speed=1, start_frame=50), Print(screen, Rainbow(screen, FigletText('Thats All')), screen.height // 2 - 5), Print(screen, Rainbow(screen, FigletText('My Kitty!')), screen.height // 2 + 5), ] scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True, start_scene=scene)
def demo(screen): scenes = [] centre = (screen.width // 2, screen.height // 2) podium = (38, 20, 30, 20) podium2 = (30, 20) # Scene 1. path = Path() path.jump_to(-20, centre[1]) path.move_straight_to(centre[0], centre[1], 10) path.wait(30) path.move_straight_to(podium[0], podium[1], 10) path.wait(100) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "BIENVENIDO A ~~THE MINERS~~~ !!!", centre, 30), _speak(screen, "Tercera parte de Postdigital (Enrique Tomás).", podium, 110), _speak(screen, "Quiero explicarte algo sobre la obra.", podium, 180), ] scenes.append(Scene(effects)) # Scene 2. path = Path() path.jump_to(podium[0], podium[1]) path.wait(1000) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "The Miners? ... ¿Los mineros?", podium, 10), _speak(screen, "Va sobre las criptomonedas y sus efectos...", podium, 80), #Print(screen, # Box(screen.width, screen.height, uni=screen.unicode_aware), # 0, 0, start_frame=90), _speak(screen, "Las criptomonedas son dinero electrónico.", podium, 150), _speak( screen, "Sirven para transferir dinero sin intermediarios (como los bancos).", podium, 220), _speak2( screen, "Las transacciones necesitan ser verificadas por otros ordenadores de la red", podium, 300), _speak(screen, "que resuelven un complejo problema matemático.", podium, 400), _speak(screen, "...consumiendo mucha electricidad.", podium, 480), _speak2(screen, "Al año, tanta como un país como Irlanda o Suiza.", podium, 580), _speak(screen, "Por este motivo se recompensa económicamente a los nodos.", podium, 700), _speak2( screen, "El primero en resolverlo gana 12.5 bitcoins (1 bitcoin =~ 4200 euro) ", podium, 780), Stars(screen, (screen.width + screen.height) // 2, start_frame=360) ] scenes.append(Scene(effects, -1)) # Scene 3. path = Path() path.move_straight_to(podium[2], podium[3], 10) path.wait(800) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "Durante esta obra, vamos a minar bitcoins...", podium2, 10), _speak2(screen, "Cada nota que tocará el Emsemble Container...", podium2, 70), _speak2( screen, "verificará (minará) una transaccion de bitcoins en tiempo real", podium2, 160), _speak(screen, " y si tenemos suerte (1 elevado a menos 36)...", podium2, 260), _speak(screen, "¡¡¡ganaremos 12.5 bitcoins en este concierto!!!", podium2, 340), _speak(screen, "El minado (ejem... el concierto) va a empezar...", podium2, 420), RandomNoise(screen, signal=Rainbow( screen, FigletText("El concierto... va a empezar...", font="term")), start_frame=490) ] scenes.append(Scene(effects, -1)) screen.play(scenes, stop_on_resize=True)
def demo(screen): scenes = [] centre = (screen.width // 2, screen.height // 2) podium = (8, 5) # Scene 1. path = Path() path.jump_to(-20, centre[1]) path.move_straight_to(centre[0], centre[1], 10) path.wait(30) path.move_straight_to(podium[0], podium[1], 10) path.wait(100) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "WELCOME TO ASCIIMATICS", centre, 30), _speak(screen, "My name is Aristotle Arrow.", podium, 110), _speak(screen, "I'm here to help you learn ASCIImatics.", podium, 180), ] scenes.append(Scene(effects)) # Scene 2. path = Path() path.jump_to(podium[0], podium[1]) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "Let's start with the Screen...", podium, 10), _speak(screen, "This is your Screen object.", podium, 80), Print(screen, Box(screen.width, screen.height, uni=screen.unicode_aware), 0, 0, start_frame=90), _speak(screen, "It lets you play a Scene like this one I'm in.", podium, 150), _speak(screen, "A Scene contains one or more Effects.", podium, 220), _speak(screen, "Like me - I'm a Sprite!", podium, 290), _speak(screen, "Or these Stars.", podium, 360), _speak(screen, "As you can see, the Screen handles them both at once.", podium, 430), _speak(screen, "It can handle as many Effects as you like.", podium, 500), _speak(screen, "Please press <SPACE> now.", podium, 570), Stars(screen, (screen.width + screen.height) // 2, start_frame=360) ] scenes.append(Scene(effects, -1)) # Scene 3. path = Path() path.jump_to(podium[0], podium[1]) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "This is a new Scene.", podium, 10), _speak( screen, "The Screen stops all Effects and clears itself between " "Scenes.", podium, 70), _speak(screen, "That's why you can't see the Stars now.", podium, 130), _speak(screen, "(Though you can override that if you need to.)", podium, 200), _speak(screen, "Please press <SPACE> now.", podium, 270), ] scenes.append(Scene(effects, -1)) # Scene 4. path = Path() path.jump_to(podium[0], podium[1]) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "So, how do you design your animation?", podium, 10), _speak(screen, "1) Decide on your cinematic flow of Scenes.", podium, 80), _speak(screen, "2) Create the Effects in each Scene.", podium, 150), _speak(screen, "3) Pass the Scenes to the Screen to play.", podium, 220), _speak(screen, "It really is that easy!", podium, 290), _speak(screen, "Just look at this sample code.", podium, 360), _speak(screen, "Please press <SPACE> now.", podium, 430), ] scenes.append(Scene(effects, -1)) # Scene 5. path = Path() path.jump_to(podium[0], podium[1]) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "There are various effects you can use. For " "example...", podium, 10), Cycle(screen, FigletText("Colour cycling"), centre[1] - 5, start_frame=100), Cycle(screen, FigletText("using Figlet"), centre[1] + 1, start_frame=100), _speak(screen, "Look in the effects module for more...", podium, 290), _speak(screen, "Please press <SPACE> now.", podium, 360), ] scenes.append(Scene(effects, -1)) # Scene 6. path = Path() path.jump_to(podium[0], podium[1]) curve_path = [] for i in range(0, 11): curve_path.append( (centre[0] + (screen.width / 4 * math.sin(i * math.pi / 5)), centre[1] - (screen.height / 4 * math.cos(i * math.pi / 5)))) path2 = Path() path2.jump_to(centre[0], centre[1] - screen.height // 4) path2.move_round_to(curve_path, 60) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "Sprites (like me) are also an Effect.", podium, 10), _speak(screen, "We take a pre-defined Path to follow.", podium, 80), _speak(screen, "Like this one...", podium, 150), Plot(screen, path2, colour=Screen.COLOUR_BLUE, start_frame=160, stop_frame=300), _speak(screen, "My friend Sam will now follow it...", podium, 320), Sam(screen, copy.copy(path2), start_frame=380), _speak(screen, "Please press <SPACE> now.", podium, 420), ] scenes.append(Scene(effects, -1)) # Scene 7. path = Path() path.jump_to(podium[0], podium[1]) path.wait(60) path.move_straight_to(-5, podium[1], 20) path.wait(300) effects = [ Arrow(screen, path, colour=Screen.COLOUR_GREEN), _speak(screen, "Goodbye!", podium, 10), Cycle(screen, FigletText("THE END!"), centre[1] - 4, start_frame=100), Print(screen, SpeechBubble("Press X to exit"), centre[1] + 6, start_frame=150) ] scenes.append(Scene(effects, 500)) screen.play(scenes, stop_on_resize=True)
def test_init(self): # Most of the function in these classes is actually in the Sprite # base Effect - so just check we can build these classes self.assertIsNotNone(Sam(None, Path())) self.assertIsNotNone(Arrow(None, Path())) self.assertIsNotNone(Plot(None, Path()))