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. Callingrender()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, andskip_animationsproperties 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 to the output at the current scene time.
Add a subcaption at the current scene time.
Run the managed scene's
construct()hook.Create a new output section.
Coordinate an animation request and its optional subcaption.
Finalize output after scene construction and tear-down.
Run the complete render lifecycle for the managed scene.
Run the managed scene's
setup()hook.Run the managed scene's
tear_down()hook.Attributes
Return the current renderer's camera.
Return the current renderer's file writer.
Return the current renderer's play count.
Return the immutable output intent captured for this session.
Return the scene's current renderer.
Return the immutable artifact, presentation, and execution intent.
Return the current renderer's animation skip state.
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
- 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(), andpost_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:
Truewhen an interactive rerun was requested; otherwiseFalse. This matches the return value ofrender().- 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.
- 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.