Manager

Qualified name: manim.manager.Manager

class Manager(scene)[source]

Bases: Generic[SceneT]

Coordinate the render lifecycle for a single scene.

A manager is attached to exactly one Scene. It coordinates the scene lifecycle, delegates animation playback to the current renderer, and routes section, subcaption, and audio operations to the current file writer. Calling render() creates a manager lazily when one has not already been attached.

Parameters:

scene (SceneT) – The scene coordinated by this manager. A scene that already has a manager cannot be attached to another one.

scene

The managed scene.

Notes

This class is the coordination boundary for an incremental render-flow refactor. Renderer, camera, clock, and output ownership still remain on the scene and renderer for compatibility. The renderer, camera, file_writer, time, num_plays, and skip_animations properties are forwarding views for now.

Examples

A scene normally creates its manager when render() is called. It can also be attached explicitly:

scene = Scene()
manager = Manager(scene)
manager.render()

Methods

add_sound

Add sound to the output at the current scene time.

add_subcaption

Add a subcaption at the current scene time.

construct

Run the managed scene's construct() hook.

next_section

Create a new output section.

play

Coordinate an animation request and its optional subcaption.

post_construct

Finalize output after scene construction and tear-down.

render

Run the complete render lifecycle for the managed scene.

setup

Run the managed scene's setup() hook.

tear_down

Run the managed scene's tear_down() hook.

Attributes

camera

Return the current renderer's camera.

file_writer

Return the current renderer's file writer.

num_plays

Return the current renderer's play count.

output_spec

Return the immutable output intent captured for this session.

renderer

Return the scene's current renderer.

session_spec

Return the immutable artifact, presentation, and execution intent.

skip_animations

Return the current renderer's animation skip state.

time

Return the current renderer time.

add_sound(sound_file, time_offset=0, gain=None, **kwargs)[source]

Add sound to the output at the current scene time.

No sound is added while animations are being skipped.

Parameters:
  • sound_file (str) – The path to the sound file.

  • time_offset (float) – The offset in seconds from the current scene time.

  • gain (float | None) – The gain adjustment applied to the sound.

  • kwargs (Any) – Additional arguments forwarded to add_sound().

Return type:

None

add_subcaption(content, duration=1, offset=0)[source]

Add a subcaption at the current scene time.

Parameters:
  • content (str) – The subcaption text.

  • duration (float) – The duration in seconds for which the subcaption is displayed.

  • offset (float) – The offset in seconds from the current scene time.

Return type:

None

property camera: Camera | OpenGLCamera

Return the current renderer’s camera.

construct()[source]

Run the managed scene’s construct() hook.

Return type:

None

property file_writer: SceneFileWriter

Return the current renderer’s file writer.

next_section(name='unnamed', section_type=DefaultSectionType.NORMAL, skip_animations=False)[source]

Create a new output section.

Parameters:
  • name (str) – The section name.

  • section_type (str) – The section type stored in the section manifest.

  • skip_animations (bool) – Whether animation output in this section should be skipped.

Return type:

None

property num_plays: int

Return the current renderer’s play count.

property output_spec: OutputSpec

Return the immutable output intent captured for this session.

play(*args, subcaption=None, subcaption_duration=None, subcaption_offset=0, **kwargs)[source]

Coordinate an animation request and its optional subcaption.

Parameters:
  • args (Animation | Mobject | _AnimationBuilder) – Animations, mobjects, or animation builders passed by play().

  • subcaption (str | None) – Content to add to the external subcaption file for this play call.

  • subcaption_duration (float | None) – Duration of the subcaption. When omitted, the elapsed animation time is used.

  • subcaption_offset (float) – Offset in seconds from the beginning of the play call.

  • kwargs (Any) – Additional animation arguments forwarded to the renderer.

Return type:

None

post_construct()[source]

Finalize output after scene construction and tear-down.

This validates empty video output, asks the renderer to finish the scene, and logs the number of played animations. It intentionally runs after tear_down() to preserve the established render lifecycle.

Return type:

None

render(preview=False)[source]

Run the complete render lifecycle for the managed scene.

The lifecycle invokes setup(), construct(), tear_down(), and post_construct(), in that order. Reaching a configured animation boundary ends construction normally. Exceptions raised while constructing the scene abort active encoding jobs before they are propagated.

Parameters:

preview (bool) – Whether the rendered media should be opened after rendering.

Returns:

True when an interactive rerun was requested; otherwise False. This matches the return value of render().

Return type:

bool

property renderer: CairoRenderer | OpenGLRenderer

Return the scene’s current renderer.

property session_spec: RenderSessionSpec

Return the immutable artifact, presentation, and execution intent.

setup()[source]

Run the managed scene’s setup() hook.

Return type:

None

property skip_animations: bool

Return the current renderer’s animation skip state.

tear_down()[source]

Run the managed scene’s tear_down() hook.

Return type:

None

property time: float

Return the current renderer time.