API 参考:场景(scene)

共 10 个类,按字母排序。每个类含中文说明、继承链、参数表与上手示例,API 文档由 autodoc 从 manim v0.21.0 源码自动生成;带完整中文精讲的类见 API 索引。

DefaultSectionType

章节类型枚举:normal/skip/speedup,控制分节导出时该节的处理方式。

API 文档

class manim.DefaultSectionType(*values)

基类:StrEnum

The type of a section can be used for third party applications. A presentation system could for example use the types to created loops.

Examples

This class can be reimplemented for more types:

class PresentationSectionType(str, Enum):
    # start, end, wait for continuation by user
    NORMAL = "presentation.normal"
    # start, end, immediately continue to next section
    SKIP = "presentation.skip"
    # start, end, restart, immediately continue to next section when continued by user
    LOOP = "presentation.loop"
    # start, end, restart, finish animation first when user continues
    COMPLETE_LOOP = "presentation.complete_loop"

LinearTransformationScene

线性变换演示场景:自带基向量网格与 apply_matrix 快捷方法,线代可视化开箱即用。

继承关系

digraph G { graph [rankdir=LR, bgcolor="transparent", splines=spline, concentrate=true, nodesep="0.15", ranksep="0.3"]; node [shape=box, penwidth=0, width=0.05, height=0.05, margin=0.05]; edge [penwidth=1]; "Scene" -> "VectorScene"; "VectorScene" -> "LinearTransformationScene"; }

参数

include_background_plane

True,bool

include_foreground_plane

True,bool

background_plane_kwargs

None,dict[str, Any] | None

foreground_plane_kwargs

None,dict[str, Any] | None

show_coordinates

False,bool

show_basis_vectors

True,bool

basis_vector_stroke_width

6,float

i_hat_color

ManimColor('#83C167'),ParsableManimColor

j_hat_color

ManimColor('#FC6255'),ParsableManimColor

leave_ghost_vectors

False,bool

快速上手

class Demo(LinearTransformationScene):
    def construct(self):
        self.apply_matrix([[1, 1], [0, 1]])

API 文档

class manim.LinearTransformationScene(include_background_plane: bool = True, include_foreground_plane: bool = True, background_plane_kwargs: dict[str, Any] | None = None, foreground_plane_kwargs: dict[str, Any] | None = None, show_coordinates: bool = False, show_basis_vectors: bool = True, basis_vector_stroke_width: float = 6, i_hat_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#83C167'), j_hat_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FC6255'), leave_ghost_vectors: bool = False, **kwargs: Any)

基类:VectorScene

This scene contains special methods that make it especially suitable for showing linear transformations.

Parameters

include_background_plane

Whether or not to include the background plane in the scene.

include_foreground_plane

Whether or not to include the foreground plane in the scene.

background_plane_kwargs

Parameters to be passed to NumberPlane to adjust the background plane.

foreground_plane_kwargs

Parameters to be passed to NumberPlane to adjust the foreground plane.

show_coordinates

Whether or not to include the coordinates for the background plane.

show_basis_vectors

Whether to show the basis x_axis -> i_hat and y_axis -> j_hat vectors.

basis_vector_stroke_width

The stroke_width of the basis vectors.

i_hat_color

The color of the i_hat vector.

j_hat_color

The color of the j_hat vector.

leave_ghost_vectors

Indicates the previous position of the basis vectors following a transformation.

Examples

class LinearTransformationSceneExample(LinearTransformationScene):
    def __init__(self, **kwargs):
        LinearTransformationScene.__init__(
            self,
            show_coordinates=True,
            leave_ghost_vectors=True,
            **kwargs
        )

    def construct(self):
        matrix = [[1, 1], [0, 1]]
        self.apply_matrix(matrix)
        self.wait()
add_background_mobject(*mobjects: Mobject) → None

Adds the mobjects to the special list self.background_mobjects.

Parameters
*mobjects

The mobjects to add to the list.

add_foreground_mobject(*mobjects: Mobject) → None

Adds the mobjects to the special list self.foreground_mobjects.

Parameters
*mobjects

The mobjects to add to the list

add_moving_mobject(mobject: Mobject, target_mobject: Mobject | None = None) → None

Adds the mobject to the special list self.moving_mobject, and adds a property to the mobject called mobject.target, which keeps track of what the mobject will move to or become etc.

Parameters
mobject

The mobjects to add to the list

target_mobject

What the moving_mobject goes to, etc.

add_special_mobjects(mob_list: list[Mobject], *mobs_to_add: Mobject) → None

Adds mobjects to a separate list that can be tracked, if these mobjects have some extra importance.

Parameters
mob_list

The special list to which you want to add these mobjects.

*mobs_to_add

The mobjects to add.

add_title(title: str | MathTex | Tex, scale_factor: float = 1.5, animate: bool = False) → Self

Adds a title, after scaling it, adding a background rectangle, moving it to the top and adding it to foreground_mobjects adding it as a local variable of self. Returns the Scene.

Parameters
title

What the title should be.

scale_factor

How much the title should be scaled by.

animate

Whether or not to animate the addition.

Returns
LinearTransformationScene

The scene with the title added to it.

add_transformable_label(vector: Vector, label: MathTex | str, transformation_name: str | MathTex = 'L', new_label: str | MathTex | None = None, **kwargs: Any) → MathTex

Method for creating, and animating the addition of a transformable label for the vector.

Parameters
vector

The vector for which the label must be added.

label

The MathTex/string of the label.

transformation_name

The name to give the transformation as a label.

new_label

What the label should display after a Linear Transformation

**kwargs

Any valid keyword argument of get_vector_label

Returns
MathTex

The MathTex of the label.

add_transformable_mobject(*mobjects: Mobject) → None

Adds the mobjects to the special list self.transformable_mobjects.

Parameters
*mobjects

The mobjects to add to the list.

add_unit_square(animate: bool = False, **kwargs: Any) → Self

Adds a unit square to the scene via self.get_unit_square.

Parameters
animate

Whether or not to animate the addition with DrawBorderThenFill.

**kwargs

Any valid keyword arguments of self.get_unit_square()

Returns
Square

The unit square.

add_vector(vector: Arrow | list | tuple | ndarray, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] = ManimColor('#FFFF00'), animate: bool = False, **kwargs: Any) → Arrow

Adds a vector to the scene, and puts it in the special list self.moving_vectors.

Parameters
vector

It can be a pre-made graphical vector, or the coordinates of one.

color

The string of the hex color of the vector. This is only taken into consideration if 'vector' is not an Arrow. Defaults to YELLOW.

**kwargs

Any valid keyword argument of VectorScene.add_vector.

Returns
Arrow

The arrow representing the vector.

apply_function(function: MappingFunction, added_anims: list[Animation] = [], **kwargs: Any) → None

Applies the given function to each of the mobjects in self.transformable_mobjects, and plays the animation showing this.

Parameters
function

The function that affects each point of each mobject in self.transformable_mobjects.

added_anims

Any other animations that need to be played simultaneously with this.

**kwargs

Any valid keyword argument of a self.play() call.

apply_inverse(matrix: ndarray | list | tuple, **kwargs: Any) → None

This method applies the linear transformation represented by the inverse of the passed matrix to the number plane, and each vector/similar mobject on it.

Parameters
matrix

The matrix whose inverse is to be applied.

**kwargs

Any valid keyword argument of self.apply_matrix()

apply_inverse_transpose(t_matrix: ndarray | list | tuple, **kwargs: Any) → None

Applies the inverse of the transformation represented by the given transposed matrix to the number plane and each vector/similar mobject on it.

Parameters
t_matrix

The matrix.

**kwargs

Any valid keyword argument of self.apply_transposed_matrix()

apply_matrix(matrix: ndarray | list | tuple, **kwargs: Any) → None

Applies the transformation represented by the given matrix to the number plane, and each vector/similar mobject on it.

Parameters
matrix

The matrix.

**kwargs

Any valid keyword argument of self.apply_transposed_matrix()

apply_nonlinear_transformation(function: Callable[[ndarray], ndarray], **kwargs: Any) → None

Applies the non-linear transformation represented by the given function to the number plane and each vector/similar mobject on it.

Parameters
function

The function.

**kwargs

Any valid keyword argument of self.apply_function()

apply_transposed_matrix(transposed_matrix: ndarray | list | tuple, **kwargs: Any) → None

Applies the transformation represented by the given transposed matrix to the number plane, and each vector/similar mobject on it.

Parameters
transposed_matrix

The matrix.

**kwargs

Any valid keyword argument of self.apply_function()

get_ghost_vectors() → VGroup

Returns all ghost vectors ever added to self. Each element is a VGroup of two ghost vectors.

get_matrix_transformation(matrix: np.ndarray | list | tuple) → Callable[[Point3D], Point3D]

Returns a function corresponding to the linear transformation represented by the matrix passed.

Parameters
matrix

The matrix.

get_moving_mobject_movement(func: MappingFunction) → Transform

This method returns an animation that moves a mobject in "self.moving_mobjects" to its corresponding .target value. func is a function that determines where the .target goes.

Parameters
func

The function that determines where the .target of the moving mobject goes.

Returns
Animation

The animation of the movement.

get_piece_movement(pieces: Iterable[Mobject]) → Transform

This method returns an animation that moves an arbitrary mobject in "pieces" to its corresponding .target value. If self.leave_ghost_vectors is True, ghosts of the original positions/mobjects are left on screen

Parameters
pieces

The pieces for which the movement must be shown.

Returns
Animation

The animation of the movement.

get_transformable_label_movement() → Transform

This method returns an animation that moves all labels in "self.transformable_labels" to its corresponding .target .

Returns
Animation

The animation of the movement.

get_transposed_matrix_transformation(transposed_matrix: np.ndarray | list | tuple) → Callable[[Point3D], Point3D]

Returns a function corresponding to the linear transformation represented by the transposed matrix passed.

Parameters
transposed_matrix

The matrix.

get_unit_square(color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | Iterable[ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float]] = ManimColor('#FFFF00'), opacity: float = 0.3, stroke_width: float = 3) → Rectangle

Returns a unit square for the current NumberPlane.

Parameters
color

The string of the hex color code of the color wanted.

opacity

The opacity of the square

stroke_width

The stroke_width in pixels of the border of the square

Returns

Square

get_vector_movement(func: MappingFunction) → Transform

This method returns an animation that moves a mobject in "self.moving_vectors" to its corresponding .target value. func is a function that determines where the .target goes.

Parameters
func

The function that determines where the .target of the moving mobject goes.

Returns
Animation

The animation of the movement.

setup() → None

This is meant to be implemented by any scenes which are commonly subclassed, and have some common setup involved before the construct method is called.

write_vector_coordinates(vector: Vector, **kwargs: Any) → Matrix

Returns a column matrix indicating the vector coordinates, after writing them to the screen, and adding them to the special list self.foreground_mobjects

Parameters
vector

The arrow representing the vector.

**kwargs

Any valid keyword arguments of VectorScene.write_vector_coordinates

Returns
Matrix

The column matrix representing the vector.

MovingCameraScene

镜头运动场景:self.camera.frame 自由推拉摇移,适合走遍整张图的讲解。

继承关系

digraph G { graph [rankdir=LR, bgcolor="transparent", splines=spline, concentrate=true, nodesep="0.15", ranksep="0.3"]; node [shape=box, penwidth=0, width=0.05, height=0.05, margin=0.05]; edge [penwidth=1]; "Scene" -> "MovingCameraScene"; }

参数

快速上手

self.play(self.camera.frame.animate.scale(0.5).shift(RIGHT))

API 文档

class manim.MovingCameraScene(camera_class: type[Camera] = <class 'manim.camera.moving_camera.MovingCamera'>, **kwargs: Any)

基类:Scene

This is a Scene, with special configurations and properties that make it suitable for cases where the camera must be moved around.

Note: Examples are included in the moving_camera_scene module documentation, see below in the 'see also' section.

参见

moving_camera_scene MovingCamera

get_moving_mobjects(*animations: Animation) → list[Mobject]

This method returns a list of all of the Mobjects in the Scene that are moving, that are also in the animations passed.

Parameters

*animations

The Animations whose mobjects will be checked.

Scene

场景基类:一切动画的主入口。construct() 里用 add/play 编排,掌握 Scene 就掌握了 Manim 的导演椅。

参数

renderer

None

camera_class

<class 'manim.camera.camera…,type[Camera]

always_update_mobjects

False,bool

random_seed

None,int | None

skip_animations

False,bool

快速上手

class Demo(Scene):
    def construct(self):
        self.play(Write(Text("Hello")))

API 文档

class manim.Scene(renderer: CairoRenderer | OpenGLRenderer | None = None, camera_class: type[Camera] = <class 'manim.camera.camera.Camera'>, always_update_mobjects: bool = False, random_seed: int | None = None, skip_animations: bool = False)

基类:object

A Scene is the canvas of your animation.

The primary role of Scene is to provide the user with tools to manage mobjects and animations. Generally speaking, a manim script consists of a class that derives from Scene whose Scene.construct() method is overridden by the user's code.

Mobjects are displayed on screen by calling Scene.add() and removed from screen by calling Scene.remove(). All mobjects currently on screen are kept in Scene.mobjects. Animations are played by calling Scene.play().

A Scene is rendered internally by calling Scene.render(). This in turn calls Scene.setup(), Scene.construct(), and Scene.tear_down(), in that order.

It is not recommended to override the __init__ method in user Scenes. For code that should be ran before a Scene is rendered, use Scene.setup() instead.

Examples

Override the Scene.construct() method with your code.

class MyScene(Scene):
    def construct(self):
        self.play(Write(Text("Hello World!")))
add(*mobjects: Mobject | OpenGLMobject) → Self

Mobjects will be displayed, from background to foreground in the order with which they are added.

Parameters
*mobjects

Mobjects to add.

Returns
Scene

The same scene after adding the Mobjects in.

add_foreground_mobject(mobject: Mobject) → Scene

Adds a single mobject to the foreground, and internally to the list foreground_mobjects, and mobjects.

Parameters
mobject

The Mobject to add to the foreground.

Returns
Scene

The Scene, with the foreground mobject added.

add_foreground_mobjects(*mobjects: Mobject) → Scene

Adds mobjects to the foreground, and internally to the list foreground_mobjects, and mobjects.

Parameters
*mobjects

The Mobjects to add to the foreground.

Returns
Scene

The Scene, with the foreground mobjects added.

add_sound(sound_file: str, time_offset: float = 0, gain: float | None = None, **kwargs: Any) → None

This method is used to add a sound to the animation.

Parameters
sound_file

The path to the sound file.

time_offset

The offset in the sound file after which the sound can be played.

gain

Amplification of the sound.

Examples
class SoundExample(Scene):
    # Source of sound under Creative Commons 0 License. https://freesound.org/people/Druminfected/sounds/250551/
    def construct(self):
        dot = Dot().set_color(GREEN)
        self.add_sound("click.wav")
        self.add(dot)
        self.wait()
        self.add_sound("click.wav")
        dot.set_color(BLUE)
        self.wait()
        self.add_sound("click.wav")
        dot.set_color(RED)
        self.wait()

Download the resource for the previous example here .

add_subcaption(content: str, duration: float = 1, offset: float = 0) → None

Adds an entry in the corresponding subcaption file at the current time stamp.

The current time stamp is obtained from Scene.time.

Parameters
content

The subcaption content.

duration

The duration (in seconds) for which the subcaption is shown.

offset

This offset (in seconds) is added to the starting time stamp of the subcaption.

Examples

This example illustrates both possibilities for adding subcaptions to Manimations:

class SubcaptionExample(Scene):
    def construct(self):
        square = Square()
        circle = Circle()

        # first option: via the add_subcaption method
        self.add_subcaption("Hello square!", duration=1)
        self.play(Create(square))

        # second option: within the call to Scene.play
        self.play(
            Transform(square, circle), subcaption="The square transforms."
        )
add_updater(func: Callable[[float], None]) → None

Add an update function to the scene.

The scene updater functions are run every frame, and they are the last type of updaters to run.

警告

When using the Cairo renderer, scene updaters that modify mobjects are not detected in the same way that mobject updaters are. To be more concrete, a mobject only modified via a scene updater will not necessarily be added to the list of moving mobjects and thus might not be updated every frame.

TL;DR: Use mobject updaters to update mobjects.

Parameters
func

The updater function. It takes a float, which is the time difference since the last update (usually equal to the frame rate).

See also

Scene.remove_updater() Scene.update_self()

begin_animations() → None

Start the animations of the scene.

bring_to_back(*mobjects: Mobject) → Scene

Removes the mobject from the scene and adds them to the back of the scene.

Parameters
*mobjects

The mobject(s) to push to the back of the scene.

Returns
Scene

The Scene, with the mobjects pushed to the back of the scene.

bring_to_front(*mobjects: Mobject) → Scene

Adds the passed mobjects to the scene again, pushing them to he front of the scene.

Parameters
*mobjects

The mobject(s) to bring to the front of the scene.

Returns
Scene

The Scene, with the mobjects brought to the front of the scene.

clear() → Self

Removes all mobjects present in self.mobjects and self.foreground_mobjects from the scene.

Returns
Scene

The Scene, with all of its mobjects in self.mobjects and self.foreground_mobjects removed.

compile_animation_data(*animations: Animation | Mobject | _AnimationBuilder, **play_kwargs: Any) → Self | None

Given a list of animations, compile the corresponding static and moving mobjects, and gather the animation durations.

This also begins the animations.

Parameters
animations

Animation or mobject with mobject method and params

play_kwargs

Named parameters affecting what was passed in animations, e.g. run_time, lag_ratio and so on.

Returns
self, None

None if there is nothing to play, or self otherwise.

compile_animations(*args: Animation | Mobject | _AnimationBuilder, **kwargs: Any) → list[Animation]

Creates _MethodAnimations from any _AnimationBuilders and updates animation kwargs with kwargs passed to play().

Parameters
*args

Animations to be played.

**kwargs

Configuration for the call to play().

Returns
Tuple[Animation]

Animations to be played.

construct() → None

Add content to the Scene.

From within Scene.construct(), display mobjects on screen by calling Scene.add() and remove them from screen by calling Scene.remove(). All mobjects currently on screen are kept in Scene.mobjects. Play animations by calling Scene.play().

Notes

Initialization code should go in Scene.setup(). Termination code should go in Scene.tear_down().

Examples

A typical manim script includes a class derived from Scene with an overridden Scene.construct() method:

class MyScene(Scene):
    def construct(self):
        self.play(Write(Text("Hello World!")))
See Also

Scene.setup() Scene.render() Scene.tear_down()

get_attrs(*keys: str) → list[Any]

Gets attributes of a scene given the attribute's identifier/name.

Parameters
*keys

Name(s) of the argument(s) to return the attribute of.

Returns
list

List of attributes of the passed identifiers.

get_mobject_family_members() → list[Mobject]

Returns list of family-members of all mobjects in scene. If a Circle() and a VGroup(Rectangle(),Triangle()) were added, it returns not only the Circle(), Rectangle() and Triangle(), but also the VGroup() object.

Returns
list

List of mobject family members.

get_moving_mobjects(*animations: Animation) → list[Mobject]

Gets all moving mobjects in the passed animation(s).

Parameters
*animations

The animations to check for moving mobjects.

Returns
list

The list of mobjects that could be moving in the Animation(s)

get_restructured_mobject_list(mobjects: Iterable[Mobject], to_remove: Iterable[Mobject]) → list[Mobject]

Given a list of mobjects and a list of mobjects to be removed, this filters out the removable mobjects from the list of mobjects.

Parameters
mobjects

The Mobjects to check.

to_remove

The list of mobjects to remove.

Returns
list

The list of mobjects with the mobjects to remove removed.

get_run_time(animations: list[Animation]) → float

Gets the total run time for a list of animations.

Parameters
animations

A list of the animations whose total run_time is to be calculated.

Returns
float

The total run_time of all of the animations in the list.

get_time_progression(run_time: float, description: str, n_iterations: int | None = None, override_skip_animations: bool = False) → tqdm[float]

You will hardly use this when making your own animations. This method is for Manim's internal use.

Returns a CommandLine ProgressBar whose fill_time is dependent on the run_time of an animation, the iterations to perform in that animation and a bool saying whether or not to consider the skipped animations.

Parameters
run_time

The run_time of the animation.

n_iterations

The number of iterations in the animation.

override_skip_animations

Whether or not to show skipped animations in the progress bar.

Returns
time_progression

The CommandLine Progress Bar.

get_top_level_mobjects() → list[Mobject]

Returns all mobjects which are not submobjects.

Returns
list

List of top level mobjects.

interactive_embed() → None

Like embed(), but allows for screen interaction.

is_current_animation_frozen_frame() → bool

Returns whether the current animation produces a static frame (generally a Wait).

next_section(name: str = 'unnamed', section_type: str = DefaultSectionType.NORMAL, skip_animations: bool = False) → None

Create separation here; the last section gets finished and a new one gets created. skip_animations skips the rendering of all animations in this section. Refer to the documentation</tutorials/output_and_config> on how to use sections.

pause(duration: float = 1.0) → None

Pauses the scene (i.e., displays a frozen frame).

This is an alias for wait() with frozen_frame set to True.

Parameters
duration

The duration of the pause.

See also

wait(), Wait

play(*args: Animation | Mobject | _AnimationBuilder, subcaption: str | None = None, subcaption_duration: float | None = None, subcaption_offset: float = 0, **kwargs: Any) → None

Plays an animation in this scene.

Parameters
args

Animations to be played.

subcaption

The content of the external subcaption that should be added during the animation.

subcaption_duration

The duration for which the specified subcaption is added. If None (the default), the run time of the animation is taken.

subcaption_offset

An offset (in seconds) for the start time of the added subcaption.

kwargs

All other keywords are passed to the renderer.

play_internal(skip_rendering: bool = False) → None

This method is used to prep the animations for rendering, apply the arguments and parameters required to them, render them, and write them to the video file.

Parameters
skip_rendering

Whether the rendering should be skipped, by default False

remove(*mobjects: Mobject) → Self

Removes mobjects in the passed list of mobjects from the scene and the foreground, by removing them from "mobjects" and "foreground_mobjects"

Parameters
*mobjects

The mobjects to remove.

remove_foreground_mobject(mobject: Mobject) → Scene

Removes a single mobject from the foreground, and internally from the list foreground_mobjects.

Parameters
mobject

The mobject to remove from the foreground.

Returns
Scene

The Scene, with the foreground mobject removed.

remove_foreground_mobjects(*to_remove: Mobject) → Scene

Removes mobjects from the foreground, and internally from the list foreground_mobjects.

Parameters
*to_remove

The mobject(s) to remove from the foreground.

Returns
Scene

The Scene, with the foreground mobjects removed.

remove_updater(func: Callable[[float], None]) → None

Remove an update function from the scene.

Parameters
func

The updater function to be removed.

See also

Scene.add_updater() Scene.update_self()

render(preview: bool = False) → bool

Renders this Scene.

Parameters
preview

If true, opens scene in a file viewer.

replace(old_mobject: Mobject, new_mobject: Mobject) → None

Replace one mobject in the scene with another, preserving draw order.

If old_mobject is a submobject of some other Mobject (e.g. a Group), the new_mobject will replace it inside the group, without otherwise changing the parent mobject.

Parameters
old_mobject

The mobject to be replaced. Must be present in the scene.

new_mobject

A mobject which must not already be in the scene.

restructure_mobjects(to_remove: Sequence[Mobject], mobject_list_name: str = 'mobjects', extract_families: bool = True) → Scene
tl:wr

If your scene has a Group(), and you removed a mobject from the Group, this dissolves the group and puts the rest of the mobjects directly in self.mobjects or self.foreground_mobjects.

In cases where the scene contains a group, e.g. Group(m1, m2, m3), but one of its submobjects is removed, e.g. scene.remove(m1), the list of mobjects will be edited to contain other submobjects, but not m1, e.g. it will now insert m2 and m3 to where the group once was.

Parameters
to_remove

The Mobject to remove.

mobject_list_name

The list of mobjects ("mobjects", "foreground_mobjects" etc) to remove from.

extract_families

Whether the mobject's families should be recursively extracted.

Returns
Scene

The Scene mobject with restructured Mobjects.

setup() → None

This is meant to be implemented by any scenes which are commonly subclassed, and have some common setup involved before the construct method is called.

should_update_mobjects() → bool

Returns True if the mobjects of this scene should be updated.

In particular, this checks whether

  • the always_update_mobjects attribute of Scene is set to True,

  • the Scene itself has time-based updaters attached,

  • any mobject in this Scene has time-based updaters attached.

This is only called when a single Wait animation is played.

tear_down() → None

This is meant to be implemented by any scenes which are commonly subclassed, and have some common method to be invoked before the scene ends.

property time: float

The time since the start of the scene.

update_mobjects(dt: float) → None

Begins updating all mobjects in the Scene.

Parameters
dt

Change in time between updates. Defaults (mostly) to 1/frames_per_second

update_self(dt: float) → None

Run all scene updater functions.

Among all types of update functions (mobject updaters, mesh updaters, scene updaters), scene update functions are called last.

Parameters
dt

Scene time since last update.

See Also

Scene.add_updater() Scene.remove_updater()

wait(duration: float = 1.0, stop_condition: Callable[[], bool] | None = None, frozen_frame: bool | None = None) → None

Plays a "no operation" animation.

Parameters
duration

The run time of the animation.

stop_condition

A function without positional arguments that is evaluated every time a frame is rendered. The animation only stops when the return value of the function is truthy, or when the time specified in duration passes.

frozen_frame

If True, updater functions are not evaluated, and the animation outputs a frozen frame. If False, updater functions are called and frames are rendered as usual. If None (the default), the scene tries to determine whether or not the frame is frozen on its own.

See also

Wait, should_mobjects_update()

wait_until(stop_condition: Callable[[], bool], max_time: float = 60) → None

Wait until a condition is satisfied, up to a given maximum duration.

Parameters
stop_condition

A function with no arguments that determines whether or not the scene should keep waiting.

max_time

The maximum wait time in seconds.

SceneFileWriter

负责把场景帧编码输出为视频/图片文件:分辨率、帧率、分段导出都由它落盘。

参数

renderer

—

scene_name

—,str

API 文档

class manim.SceneFileWriter(renderer: CairoRenderer | OpenGLRenderer, scene_name: str, **kwargs: Any)

基类:object

SceneFileWriter is the object that actually writes the animations played, into video files, using FFMPEG. This is mostly for Manim's internal use. You will rarely, if ever, have to use the methods for this class, unless tinkering with the very fabric of Manim's reality.

Attributes

sectionslist of Section

used to segment scene

sections_output_dirpathlib.Path

where are section videos stored

output_namestr

name of movie without extension and basis for section video names

Some useful attributes are:
"write_to_movie" (bool=False)

Whether or not to write the animations into a video file.

"movie_file_extension" (str=".mp4")

The file-type extension of the outputted video.

"partial_movie_files"

List of all the partial-movie files.

abort_encode_jobs(reraise_encoder_failures: bool = False) → None

Tear down encode jobs after an aborted or rerun render.

Seals the current job so its worker can exit (a non-daemon thread blocked on the queue would hang the process at exit), then deletes its partial file unconditionally: an aborted partial is structurally valid but truncated, so leaving it behind produces an erroneous cache hit on a later run. Sealed in-flight jobs are then drained. With reraise_encoder_failures=False (a render exception is already propagating) drain failures are logged, not raised; with True (rerun path -- no primary exception exists) the first drain failure propagates so corrupt completed partials cannot be silently ignored.

add_audio_segment(new_segment: AudioSegment, time: float | None = None, gain_to_background: float | None = None) → None

This method adds an audio segment from an AudioSegment type object and suitable parameters.

Parameters
new_segment

The audio segment to add

time

the timestamp at which the sound should be added.

gain_to_background

The gain of the segment from the background.

add_partial_movie_file(hash_animation: str | None) → None

Adds a new partial movie file path to scene.partial_movie_files and current section from a hash.

This method will compute the path from the hash. In addition to that it adds the new animation to the current section.

Parameters
hash_animation

Hash of the animation.

add_sound(sound_file: StrPath, time: float | None = None, gain: float | None = None, **kwargs: Any) → None

This method adds an audio segment from a sound file.

Parameters
sound_file

The path to the sound file.

time

The timestamp at which the audio should be added.

gain

The gain of the given audio segment.

**kwargs

This method uses add_audio_segment, so any keyword arguments used there can be referenced here.

begin_animation(allow_write: bool = False, file_path: StrPath | None = None) → None

Used internally by manim to stream the animation to FFMPEG for displaying or writing to a file.

Parameters
allow_write

Whether or not to write to a video file.

clean_cache() → None

Will clean the cache by removing the oldest partial_movie_files.

close_partial_movie_stream() → None

Close the currently opened video container.

Used internally by Manim to first flush the remaining packages in the video stream holding a partial file, and then close the corresponding container.

combine_to_movie() → None

Used internally by Manim to combine the separate partial movie files that make up a Scene into a single video file for that Scene.

combine_to_section_videos() → None

Concatenate partial movie files for each section.

create_audio_segment() → None

Creates an empty, silent, Audio Segment.

end_animation(allow_write: bool = False) → None

Internally used by Manim to stop streaming to FFMPEG gracefully.

Parameters
allow_write

Whether or not to write to a video file.

finish() → None

Finishes writing to the FFMPEG buffer or writing images to output directory. Combines the partial movie files into the whole scene. If save_last_frame is True, saves the last frame in the default image directory.

finish_last_section() → None

Delete current section if it is empty.

flush_cache_directory() → None

Delete all the cached partial movie files

get_resolution_directory() → str

Get the name of the resolution directory directly containing the video file.

This method gets the name of the directory that immediately contains the video file. This name is <height_in_pixels_of_video>p<frame_rate>. For example, if you are rendering an 854x480 px animation at 15fps, the name of the directory that immediately contains the video, file will be 480p15.

The file structure should look something like:

MEDIA_DIR
    |--Tex
    |--texts
    |--videos
        |--<name_of_file_containing_scene>
            |--<height_in_pixels_of_video>p<frame_rate>
                |--partial_movie_files
                |--<scene_name>.mp4
                |--<scene_name>.srt
Returns
str

The name of the directory.

init_audio() → None

Preps the writer for adding audio to the movie.

init_output_directories(scene_name: str) → None

Initialise output directories.

Notes

The directories are read from config, for example config['media_dir']. If the target directories don't already exist, they will be created.

is_already_cached(hash_invocation: str) → bool

Will check if a file named with hash_invocation exists.

Parameters
hash_invocation

The hash corresponding to an invocation to either scene.play or scene.wait.

Returns
bool

Whether the file exists.

join_all_encode_jobs() → None

Join every in-flight encode job, re-raising the first failure.

next_section(name: str, type_: str, skip_animations: bool) → None

Create segmentation cut here.

open_partial_movie_stream(file_path: StrPath | None = None) → None

Open a container holding a video stream.

This is used internally by Manim initialize the container holding the video stream of a partial movie file.

print_file_ready_message(file_path: StrPath) → None

Prints the "File Ready" message to STDOUT.

save_image(image: Image) → None

This method saves the image passed to it in the default image directory.

Parameters
image

The pixel array of the image to save.

write_frame(frame_or_renderer: PixelArray | OpenGLRenderer, num_frames: int = 1) → None

Used internally by Manim to write a frame to the FFMPEG input buffer.

Parameters
frame_or_renderer

Pixel array of the frame.

num_frames

The number of times to write frame.

write_subcaption_file() → None

Writes the subcaption file.

Section

场景分节:把 construct 切成带类型的片段,配合 CLI 可导出分节视频清单。

参数

type_

—,str

video

—,str | None

name

—,str

skip_animations

—,bool

API 文档

class manim.Section(type_: str, video: str | None, name: str, skip_animations: bool)

基类:object

A Scene can be segmented into multiple Sections. Refer to the documentation</tutorials/output_and_config> for more info. It consists of multiple animations.

Attributes

type_

Can be used by a third party applications to classify different types of sections.

video

Path to video file with animations belonging to section relative to sections directory. If None, then the section will not be saved.

name

Human readable, non-unique name for this section.

skip_animations

Skip rendering the animations in this section when True.

partial_movie_files

Animations belonging to this section.

See Also

DefaultSectionType CairoRenderer.update_skipping_status() OpenGLRenderer.update_skipping_status()

get_clean_partial_movie_files() → list[str]

Return all partial movie files that are not None.

get_dict(sections_dir: Path) → dict[str, Any]

Get dictionary representation with metadata of output video.

The output from this function is used from every section to build the sections index file. The output video must have been created in the sections_dir before executing this method. This is the main part of the Segmented Video API.

is_empty() → bool

Check whether this section is empty.

Note that animations represented by None are also counted.

SpecialThreeDScene

固定相机参数的三维演示场景:低多边形默认配置,快速出 3D 效果。

继承关系

digraph G { graph [rankdir=LR, bgcolor="transparent", splines=spline, concentrate=true, nodesep="0.15", ranksep="0.3"]; node [shape=box, penwidth=0, width=0.05, height=0.05, margin=0.05]; edge [penwidth=1]; "Scene" -> "ThreeDScene"; "ThreeDScene" -> "SpecialThreeDScene"; }

参数

cut_axes_at_radius

True

camera_config

{'should_apply_shading': Tr…

three_d_axes_config

{'num_axis_pieces': 1, 'axi…

sphere_config

{'radius': 2, 'resolution':…

default_angled_camera_position

{'phi': 1.2217304763960306,…

low_quality_config

{'camera_config': {'should_…

API 文档

class manim.SpecialThreeDScene(cut_axes_at_radius=True, camera_config={'exponential_projection': True, 'should_apply_shading': True}, three_d_axes_config={'axis_config': {'numbers_with_elongated_ticks': [0, 1, 2], 'stroke_width': 2, 'tick_frequency': 1, 'unit_size': 2}, 'num_axis_pieces': 1}, sphere_config={'radius': 2, 'resolution': (24, 48)}, default_angled_camera_position={'phi': 1.2217304763960306, 'theta': -1.9198621771937625}, low_quality_config={'camera_config': {'should_apply_shading': False}, 'sphere_config': {'resolution': (12, 24)}, 'three_d_axes_config': {'num_axis_pieces': 1}}, **kwargs)

基类:ThreeDScene

An extension of ThreeDScene with more settings.

It has some extra configuration for axes, spheres, and an override for low quality rendering. Further key differences are:

  • The camera shades applicable 3DMobjects by default, except if rendering in low quality.

  • Some default params for Spheres and Axes have been added.

get_axes()

Return a set of 3D axes.

Returns

ThreeDAxes

A set of 3D axes.

get_default_camera_position()

Returns the default_angled_camera position.

Returns

dict

Dictionary of phi, theta, focal_distance, and gamma.

get_sphere(**kwargs)

Returns a sphere with the passed keyword arguments as properties.

Parameters

**kwargs

Any valid parameter of Sphere or Surface.

Returns

Sphere

The sphere object.

set_camera_to_default_position()

Sets the camera to its default position.

ThreeDScene

三维场景:自带相机朝向设置与 3D 动画辅助(如球面移动),3D 内容入口。

继承关系

digraph G { graph [rankdir=LR, bgcolor="transparent", splines=spline, concentrate=true, nodesep="0.15", ranksep="0.3"]; node [shape=box, penwidth=0, width=0.05, height=0.05, margin=0.05]; edge [penwidth=1]; "Scene" -> "ThreeDScene"; }

参数

camera_class

<class 'manim.camera.three_…

ambient_camera_rotation

None

default_angled_camera_orientation_kwargs

None

快速上手

class Demo(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=70 * DEGREES, theta=-45 * DEGREES)
        self.play(Create(Sphere()))

API 文档

class manim.ThreeDScene(camera_class=<class 'manim.camera.three_d_camera.ThreeDCamera'>, ambient_camera_rotation=None, default_angled_camera_orientation_kwargs=None, **kwargs)

基类:Scene

This is a Scene, with special configurations and properties that make it suitable for Three Dimensional Scenes.

add_fixed_in_frame_mobjects(*mobjects: Mobject)

This method is used to prevent the rotation and movement of mobjects as the camera moves around. The mobject is essentially overlaid, and is not impacted by the camera's movement in any way.

Parameters

*mobjects

The Mobjects whose orientation must be fixed.

add_fixed_orientation_mobjects(*mobjects: Mobject, **kwargs)

This method is used to prevent the rotation and tilting of mobjects as the camera moves around. The mobject can still move in the x,y,z directions, but will always be at the angle (relative to the camera) that it was at when it was passed through this method.)

Parameters

*mobjects

The Mobject(s) whose orientation must be fixed.

**kwargs
Some valid kwargs are

use_static_center_func : bool center_func : function

begin_3dillusion_camera_rotation(rate: float = 1, origin_phi: float | None = None, origin_theta: float | None = None)

This method creates a 3D camera rotation illusion around the current camera orientation.

Parameters

rate

The rate at which the camera rotation illusion should operate.

origin_phi

The polar angle the camera should move around. Defaults to the current phi angle.

origin_theta

The azimutal angle the camera should move around. Defaults to the current theta angle.

begin_ambient_camera_rotation(rate: float = 0.02, about: str = 'theta')

This method begins an ambient rotation of the camera about the Z_AXIS, in the anticlockwise direction

Parameters

rate

The rate at which the camera should rotate about the Z_AXIS. Negative rate means clockwise rotation.

about

one of 3 options: ["theta", "phi", "gamma"]. defaults to theta.

get_moving_mobjects(*animations: Animation)

This method returns a list of all of the Mobjects in the Scene that are moving, that are also in the animations passed.

Parameters

*animations

The animations whose mobjects will be checked.

move_camera(phi: float | None = None, theta: float | None = None, gamma: float | None = None, zoom: float | None = None, focal_distance: float | None = None, frame_center: Mobject | Sequence[float] | None = None, added_anims: Iterable[Animation] = [], **kwargs)

This method animates the movement of the camera to the given spherical coordinates.

Parameters

phi

The polar angle i.e the angle between Z_AXIS and Camera through ORIGIN in radians.

theta

The azimuthal angle i.e the angle that spins the camera around the Z_AXIS.

focal_distance

The radial focal_distance between ORIGIN and Camera.

gamma

The rotation of the camera about the vector from the ORIGIN to the Camera.

zoom

The zoom factor of the camera.

frame_center

The new center of the camera frame in cartesian coordinates.

added_anims

Any other animations to be played at the same time.

remove_fixed_in_frame_mobjects(*mobjects: Mobject)

This method undoes what add_fixed_in_frame_mobjects does. It allows the mobject to be affected by the movement of the camera.

Parameters

*mobjects

The Mobjects whose position and orientation must be unfixed.

remove_fixed_orientation_mobjects(*mobjects: Mobject)

This method "unfixes" the orientation of the mobjects passed, meaning they will no longer be at the same angle relative to the camera. This only makes sense if the mobject was passed through add_fixed_orientation_mobjects first.

Parameters

*mobjects

The Mobjects whose orientation must be unfixed.

set_camera_orientation(phi: float | None = None, theta: float | None = None, gamma: float | None = None, zoom: float | None = None, focal_distance: float | None = None, frame_center: Mobject | Sequence[float] | None = None, **kwargs)

This method sets the orientation of the camera in the scene.

Parameters

phi

The polar angle i.e the angle between Z_AXIS and Camera through ORIGIN in radians.

theta

The azimuthal angle i.e the angle that spins the camera around the Z_AXIS.

focal_distance

The focal_distance of the Camera.

gamma

The rotation of the camera about the vector from the ORIGIN to the Camera.

zoom

The zoom factor of the scene.

frame_center

The new center of the camera frame in cartesian coordinates.

set_to_default_angled_camera_orientation(**kwargs)

This method sets the default_angled_camera_orientation to the keyword arguments passed, and sets the camera to that orientation.

Parameters

**kwargs

Some recognised kwargs are phi, theta, focal_distance, gamma, which have the same meaning as the parameters in set_camera_orientation.

stop_3dillusion_camera_rotation()

This method stops all illusion camera rotations.

stop_ambient_camera_rotation(about='theta')

This method stops all ambient camera rotation.

VectorScene

向量演示场景:坐标系 + 向量工具方法,线性代数课场景。

继承关系

digraph G { graph [rankdir=LR, bgcolor="transparent", splines=spline, concentrate=true, nodesep="0.15", ranksep="0.3"]; node [shape=box, penwidth=0, width=0.05, height=0.05, margin=0.05]; edge [penwidth=1]; "Scene" -> "VectorScene"; }

参数

API 文档

class manim.VectorScene(basis_vector_stroke_width: float = 6.0, **kwargs: Any)

基类:Scene

add_axes(animate: bool = False, color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | Iterable[ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float]] = ManimColor('#FFFFFF')) → Axes

Adds a pair of Axes to the Scene.

Parameters

animate

Whether or not to animate the addition of the axes through Create.

color

The color of the axes. Defaults to WHITE.

add_plane(animate: bool = False, **kwargs: Any) → NumberPlane

Adds a NumberPlane object to the background.

Parameters

animate

Whether or not to animate the addition of the plane via Create.

**kwargs

Any valid keyword arguments accepted by NumberPlane.

Returns

NumberPlane

The NumberPlane object.

add_vector(vector: Arrow | Vector3DLike, color: ParsableManimColor | Iterable[ParsableManimColor] = ManimColor('#FFFF00'), animate: bool = True, **kwargs: Any) → Arrow

Returns the Vector after adding it to the Plane.

Parameters

vector

It can be a pre-made graphical vector, or the coordinates of one.

color

The string of the hex color of the vector. This is only taken into consideration if 'vector' is not an Arrow. Defaults to YELLOW.

animate

Whether or not to animate the addition of the vector by using GrowArrow

**kwargs

Any valid keyword argument of Arrow. These are only considered if vector is not an Arrow.

Returns

Arrow

The arrow representing the vector.

coords_to_vector(vector: Vector2DLike, coords_start: Point3DLike = array([2., 2., 0.]), clean_up: bool = True) → None

This method writes the vector as a column matrix (henceforth called the label), takes the values in it one by one, and form the corresponding lines that make up the x and y components of the vector. Then, an Vector() based vector is created between the lines on the Screen.

Parameters

vector

The vector to show.

coords_start

The starting point of the location of the label of the vector that shows it numerically. Defaults to 2 * RIGHT + 2 * UP or (2,2)

clean_up

Whether or not to remove whatever this method did after it's done.

get_basis_vector_labels(**kwargs: Any) → VGroup

Returns naming labels for the basis vectors.

Parameters

**kwargs
Any valid keyword arguments of get_vector_label:

vector, label (str,MathTex) at_tip (bool=False), direction (str="left"), rotate (bool), color (str), label_scale_factor=VECTOR_LABEL_SCALE_FACTOR (int, float),

get_basis_vectors(i_hat_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | Iterable[ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float]] = ManimColor('#83C167'), j_hat_color: ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float] | Iterable[ManimColor | int | str | NDArray[int64] | tuple[int, int, int] | NDArray[float64] | tuple[float, float, float] | tuple[int, int, int, int] | tuple[float, float, float, float]] = ManimColor('#FC6255')) → VGroup

Returns a VGroup of the Basis Vectors (1,0) and (0,1)

Parameters

i_hat_color

The hex colour to use for the basis vector in the x direction

j_hat_color

The hex colour to use for the basis vector in the y direction

Returns

VGroup

VGroup of the Vector Mobjects representing the basis vectors.

get_vector(numerical_vector: Vector3DLike, **kwargs: Any) → Arrow

Returns an arrow on the Plane given an input numerical vector.

Parameters

numerical_vector

The Vector to plot.

**kwargs

Any valid keyword argument of Arrow.

Returns

Arrow

The Arrow representing the Vector.

get_vector_label(vector: Vector, label: ManimTextLabel | str, at_tip: bool = False, direction: str = 'left', rotate: bool = False, color: ParsableManimColor | None = None, label_scale_factor: float = 0.8) → ManimTextLabel

Returns naming labels for the passed vector.

Parameters

vector

Vector Object for which to get the label.

at_tip

Whether or not to place the label at the tip of the vector.

direction

If the label should be on the "left" or right of the vector.

rotate

Whether or not to rotate it to align it with the vector.

color

The color to give the label.

label_scale_factor

How much to scale the label by.

Returns

ManimTextLabel

The rendered label mobject.

label_vector(vector: Vector, label: ManimTextLabel | str, animate: bool = True, **kwargs: Any) → ManimTextLabel

Shortcut method for creating, and animating the addition of a label for the vector.

Parameters

vector

The vector for which the label must be added.

label

The rendered label mobject or the string used to create one.

animate

Whether or not to animate the labelling w/ Write

**kwargs

Any valid keyword argument of get_vector_label

Returns

ManimTextLabel

The rendered label mobject.

lock_in_faded_grid(dimness: float = 0.7, axes_dimness: float = 0.5) → None

This method freezes the NumberPlane and Axes that were already in the background, and adds new, manipulatable ones to the foreground.

Parameters

dimness

The required dimness of the NumberPlane

axes_dimness

The required dimness of the Axes.

show_ghost_movement(vector: Arrow | Vector2DLike | Vector3DLike) → None

This method plays an animation that partially shows the entire plane moving in the direction of a particular vector. This is useful when you wish to convey the idea of mentally moving the entire plane in a direction, without actually moving the plane.

Parameters

vector

The vector which indicates the direction of movement.

vector_to_coords(vector: Vector3DLike, integer_labels: bool = True, clean_up: bool = True) → tuple[Matrix, Line, Line]

This method displays vector as a Vector() based vector, and then shows the corresponding lines that make up the x and y components of the vector. Then, a column matrix (henceforth called the label) is created near the head of the Vector.

Parameters

vector

The vector to show.

integer_labels

Whether or not to round the value displayed. in the vector's label to the nearest integer

clean_up

Whether or not to remove whatever this method did after it's done.

write_vector_coordinates(vector: Vector, **kwargs: Any) → Matrix

Returns a column matrix indicating the vector coordinates, after writing them to the screen.

Parameters

vector

The arrow representing the vector.

**kwargs

Any valid keyword arguments of coordinate_label():

Returns

Matrix

The column matrix representing the vector.

ZoomedScene

局部放大场景:自带放大镜窗口,主画面 + 缩放插页同时呈现细节。

继承关系

digraph G { graph [rankdir=LR, bgcolor="transparent", splines=spline, concentrate=true, nodesep="0.15", ranksep="0.3"]; node [shape=box, penwidth=0, width=0.05, height=0.05, margin=0.05]; edge [penwidth=1]; "Scene" -> "MovingCameraScene"; "MovingCameraScene" -> "ZoomedScene"; }

参数

camera_class

<class 'manim.camera.multi_…,type[Camera]

zoomed_display_height

3,float

zoomed_display_width

3,float

zoomed_display_center

None,Point3DLike | None

zoomed_display_corner

array([1., 1., 0.]),Vector3D

zoomed_display_corner_buff

0.5,float

zoomed_camera_config

{'default_frame_stroke_widt…,dict[str, Any]

zoomed_camera_image_mobject_config

{},dict[str, Any]

zoomed_camera_frame_starting_position

array([0., 0., 0.]),Point3DLike

zoom_factor

0.15,float

image_frame_stroke_width

3,float

zoom_activated

False,bool

API 文档

class manim.ZoomedScene(camera_class: type[Camera] = <class 'manim.camera.multi_camera.MultiCamera'>, zoomed_display_height: float = 3, zoomed_display_width: float = 3, zoomed_display_center: Point3DLike | None = None, zoomed_display_corner: Vector3D = array([1., 1., 0.]), zoomed_display_corner_buff: float = 0.5, zoomed_camera_config: dict[str, Any]={'background_opacity': 1, 'default_frame_stroke_width': 2}, zoomed_camera_image_mobject_config: dict[str, Any]={}, zoomed_camera_frame_starting_position: Point3DLike = array([0., 0., 0.]), zoom_factor: float = 0.15, image_frame_stroke_width: float = 3, zoom_activated: bool = False, **kwargs: Any)

基类:MovingCameraScene

This is a Scene with special configurations made for when a particular part of the scene must be zoomed in on and displayed separately.

activate_zooming(animate: bool = False) → None

This method is used to activate the zooming for the zoomed_camera.

Parameters

animate

Whether or not to animate the activation of the zoomed camera.

get_zoom_factor() → float

Returns the Zoom factor of the Zoomed camera.

Defined as the ratio between the height of the zoomed camera and the height of the zoomed mini display.

Returns

float

The zoom factor.

get_zoom_in_animation(run_time: float = 2, **kwargs: Any) → ApplyMethod

Returns the animation of camera zooming in.

Parameters

run_time

The run_time of the animation of the camera zooming in.

**kwargs

Any valid keyword arguments of ApplyMethod()

Returns

ApplyMethod

The animation of the camera zooming in.

get_zoomed_display_pop_out_animation(**kwargs: Any) → ApplyMethod

This is the animation of the popping out of the mini-display that shows the content of the zoomed camera.

Returns

ApplyMethod

The Animation of the Zoomed Display popping out.

setup() → None

This method is used internally by Manim to setup the scene for proper use.