Exemple #1
0
def demo_commenting(scene: CodeScene):
    scene.add_background(f"{example_dir}/resources/blackboard.jpg")

    code = scene.animate_code_comments(
        title="examples/commented.py",
        path=f"{example_dir}/commented.py",
        keep_comments=True,
        start_line=6,
        end_line=19,
        reset_at_end=False,
    )

    scene.highlight_line(
        code,
        number=6,
        caption="These caption callouts are "
        "automatically generated from comments when "
        "using animate_code_comments()",
    )
    scene.highlight_lines(
        code,
        start=14,
        end=18,
        caption="You can also highlight multiple "
        "lines by ending the block with '# "
        "end'",
    )
    scene.highlight_none(code)
    scene.play(FadeOut(code))
    scene.clear()
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()