[Python] How to highlight each line of code in manim?

Discussão em 'Python' iniciado por Stack, Janeiro 18, 2025.

  1. Stack

    Stack Membro Participativo

    I am working on a coding tutorial and would like to show each line of code with a surrounded rectangle (color filled ofcourse) and display an action performed as each line of the code is highlighted.

    I want my code to be on the left side of the screen and actions performed on the right side of the screen.

    So far I have written my code in a seperate .py file and have visualized it using manim's Code class. But when I draw surrounded rectangles around each line of the code, the rectangles just wildly appear in the whole window. Can you please help me how to do it?

    This is what I have done so far

    code = Code("queueDS.py", language="python", insert_line_no=True, background="window", style="monokai", fill_color=BLUE)

    for eachLine in code.code:
    surr = SurroundingRectangle(eachLine, color=BLUE, fill_opacity=0.5)

    Continue reading...

Compartilhe esta Página