def demo_highlighting(scene: CodeScene): title = PangoText( """ If you want more control, you can create code blocks and highlight them manually. """, font="Helvetica", line_spacing=0.5, ).scale(0.7) scene.play(ShowCreation(title, run_time=3, rate_func=linear)) scene.wait(2) scene.clear() scene.add_background(f"{example_dir}/resources/blackboard.jpg") tex = scene.create_code(f"{example_dir}/highlights.py") scene.play(ShowCreation(tex)) scene.highlight_line( tex, 11, caption= "Create code blocks yourself and pass in any arguments the Code class supports to do things " "like change the theme or font", ) scene.highlight_lines( tex, 13, 19, caption= "Highlight code with a caption to give extra information. A wait is" " automatically added for a time based on the length of the caption", ) scene.highlight_line(tex, 21, caption="Reset highlighting and positioning") scene.highlight_none(tex) scene.play(FadeOut(tex)) scene.clear()
def demo_sequence(scene: CodeScene): title = PangoText( """ 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="Helvetica", line_spacing=0.5, ).scale(0.7) scene.play(ShowCreation(title, run_time=4, rate_func=linear)) scene.wait(3) scene.clear() scene.add_background(f"{example_dir}/resources/blackboard.jpg") diagram = SequenceDiagram() browser, web, app = diagram.add_objects("Browser", "Web", "App") with browser: with web.text("Make a request"): web.to_target("Do a quick thing", app) with app.text("Retrieve a json object"): app.to_self("Calls itself") app.note("Do lots and lots and lots of thinking") app.ret("Value from db") web.ret("HTML response") diagram.animate(scene) scene.wait(3) scene.play(FadeOut(diagram)) scene.clear()
def goodbye(scene: CodeScene): title = PangoText( """ Try Code Video Generator today at: https://github.com/sleuth-io/code-video-generator Thanks for watching!""", font="Helvetica", line_spacing=0.5, ).scale(0.7) scene.play(ShowCreation(title, run_time=4, rate_func=linear)) scene.wait(5) scene.play(FadeOut(title))
def demo_render_self(scene: CodeScene): scene.add_background(f"{example_dir}/resources/blackboard.jpg") # Here is the code rendering this video you are watching now! code = scene.animate_code_comments( title="examples/intro.py", path=f"{example_dir}/intro.py", keep_comments=True, start_line=92, end_line=108, reset_at_end=False, ) # end scene.wait(2) scene.play(FadeOut(code)) 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()