def demo_boxes(scene: CodeScene): scene.add_background(f"{example_dir}/resources/blackboard.jpg") title = Text("examples/boxes.py", font=DEFAULT_FONT) title.to_edge(UP) scene.add(title) comp1 = TextBox("Component A", shadow=False) comp2 = TextBox("Component B", shadow=False) comp3 = TextBox("Component C", shadow=False) comp1.next_to(title, DOWN, buff=2) comp1.to_edge(LEFT) comp2.next_to(comp1, DOWN, buff=1) comp3.next_to(comp1, RIGHT, buff=4) arrow1 = Connection(comp2, comp1, "Do something") arrow2 = Connection(comp1, comp3, "Do another thing") scene.play(FadeIn(comp2)) scene.wait_until_beat(1) scene.play(Create(arrow1)) scene.play(FadeIn(comp1)) scene.wait_until_beat(1) scene.play(Create(arrow2)) scene.play(FadeIn(comp3)) scene.wait_until_beat(4) scene.clear()
def demo_sequence(scene: CodeScene): title = Text( """ You can use Code Video Generator to also illustrate high-level concepts through sequence diagrams, or if you want more control, your own block diagrams: """, font=DEFAULT_FONT, line_spacing=0.5, ).scale(0.7) scene.play(Create(title, run_time=4, rate_func=linear)) scene.wait(3) scene.clear() scene.add_background(f"{example_dir}/resources/blackboard.jpg") title = Text("examples/sequence-diagrams.py", font=DEFAULT_FONT) title.to_edge(UP) scene.add(title) diagram = AutoScaled(SequenceDiagram()) browser, web, app = diagram.add_objects("Browser", "Web", "App") browser.to(web, "Make a request") web.to(app, "Request with no response") web.to(app, "Retrieve a json object") app.to(app, "Calls itself") app.note("Do lots and lots and lots of thinking") app.to(web, "Value from db") web.to(browser, "HTML response") diagram.next_to(title, DOWN) scene.play(Create(diagram)) for interaction in diagram.get_interactions(): scene.play(Create(interaction)) scene.wait(3) scene.play(FadeOut(diagram), *[FadeOut(item) for item in diagram.interactions]) scene.clear()