Utilities

CodeVideoRenderer.utils.noManimOutput() Generator[None, Any, None][source]

Context manager used to execute code without outputting Manim logs.

CodeVideoRenderer.utils.stripEmptyLines(text: str) str[source]

Remove empty lines from the beginning and end of a string.

Parameters:

text (str) – The input string to process.

Returns:

The string with empty lines removed from the beginning and end.

Return type:

str

CodeVideoRenderer.utils.typeName(item_type: Any) str[source]

Get the name of a type, handling union types and generic types.

Parameters:

item_type – The type or value to get the name of.

Returns:

The name of the type.

Return type:

str

CodeVideoRenderer.utils.addGlowEffect(input_path: str | PathLike, output_path: str | PathLike, output: bool) None[source]

Add a glow effect to a video.

Parameters:
  • input_path (StrPath) – Path to the input video file.

  • output_path (StrPath) – Path to save the output video file.

  • output (bool) – Whether to display progress bars.

Returns:

None

CodeVideoRenderer.utils.findSpacePositions(string: str) List[List[int]][source]

Find the 2D positions of all non-leading, non-trailing spaces in a string. Each position is represented as a list [row_index, column_index].

Parameters:

string (str) – A string.

Returns:

A list of 2D positions of all non-leading, non-trailing spaces. Each position is represented as a list [row_index, column_index].

Return type:

List[List[int]]

CodeVideoRenderer.utils.findEmptyLinePositions(string: str) List[int][source]

Find the line indices of all empty lines in a string.

Parameters:

string (str) – A string.

Returns:

A list of line indices of all empty lines.

Return type:

List[int]

CodeVideoRenderer.utils.replaceMiddleSpacesWithOccupyCharacter(string: str) str[source]

Replace all non-leading, non-trailing spaces in the input string with OCCUPY_CHARACTER. Retain leading and trailing spaces.

Parameters:

string (str) – Original string.

Returns:

Processed string with middle spaces replaced by OCCUPY_CHARACTER.

Return type:

str

class CodeVideoRenderer.utils.DefaultProgressBar(*args: Any, **kwargs: Any)[source]

Default progress bar.

class CodeVideoRenderer.utils.RichProgressBarLogger(*args: Any, **kwargs: Any)[source]

A progress logger that uses Rich to display progress bars.

new_tqdm_bar(bar)[source]

Create a Rich progress bar task for the given bar.

close_tqdm_bar(bar)[source]

Close the Rich progress bar task for the given bar.

bars_callback(bar, attr, value, old_value)[source]

Update the Rich progress bar task based on the attribute change.

stop()[source]

Stop the Rich progress bar.