ワンクリックで
manimlib-animations-animations
// Reference for manimlib animation primitives, transform families, and timing patterns used with self.play().
// Reference for manimlib animation primitives, transform families, and timing patterns used with self.play().
Generate and validate video_script.jsonl from a code repository (GitHub URL or local path). Use this when running phase 1 of the repo-to-video pipeline.
Generate and validate video_script.jsonl from a specific paper URL or pasted paper content. Use this when running phase 1 of the paper-to-video pipeline.
| name | manimlib-animations-animations |
| description | Reference for manimlib animation primitives, transform families, and timing patterns used with self.play(). |
| metadata | {"short-description":"manimlib animation API reference"} |
All animations are passed to self.play(). Multiple animations in the same self.play() call run simultaneously.
self.play(anim1, anim2, anim3) # All at once
self.play(anim1, anim2, run_time=2) # Override run_time for all
self.play(anim1, rate_func=linear) # Override rate function for all
The go-to animation for text and Tex. Draws the border then fills.
self.play(Write(text)) # Auto-calculates run_time based on length
self.play(Write(tex, run_time=3)) # Manual run_time
self.play(Write(tex, rate_func=linear)) # Default uses linear
Write extends DrawBorderThenFill:
run_time defaults to 1 for < 15 submobjects, 2 otherwiselag_ratio is auto-calculated: min(4.0 / (family_size + 1.0), 0.2)Draws a VMobject from start to end along its path. Great for lines, curves, graphs.
self.play(ShowCreation(line))
self.play(ShowCreation(circle, run_time=2))
self.play(ShowCreation(graph))
# Default lag_ratio=1.0 (each submobject draws one at a time)
Reverse of ShowCreation -- erases from end to start.
self.play(Uncreate(line)) # remover=True by default, removes from scene when done
Like Write but more configurable.
self.play(DrawBorderThenFill(shape))
self.play(DrawBorderThenFill(shape, stroke_width=3, stroke_color=YELLOW))
# Default run_time=2, rate_func=double_smooth
Shows text word by word.
self.play(AddTextWordByWord(text, time_per_word=0.2))
# run_time is auto-calculated: time_per_word * num_words
# Progressively show more submobjects
self.play(ShowIncreasingSubsets(VGroup(*dots), run_time=3))
# Show one submobject at a time (each replaces previous)
self.play(ShowSubmobjectsOneByOne(VGroup(*dots), run_time=3))
self.play(FadeIn(mob)) # Simple fade in
self.play(FadeIn(mob, shift=UP)) # Fade in while sliding up
self.play(FadeIn(mob, shift=LEFT * 2)) # Fade in from right
self.play(FadeIn(mob, scale=0.5)) # Fade in while growing (starts at 0.5x)
self.play(FadeIn(mob, shift=DOWN, scale=2)) # Combine shift and scale
self.play(FadeOut(mob)) # Simple fade out (remover=True)
self.play(FadeOut(mob, shift=DOWN)) # Fade out sliding down
self.play(FadeOut(mob, scale=0.5)) # Fade out while shrinking
self.play(FadeInFromPoint(mob, point=ORIGIN)) # Grows from a specific point
self.play(FadeOutToPoint(mob, point=UP * 3)) # Shrinks to a specific point
Cross-fades between two different mobjects by matching their shapes/positions.
self.play(FadeTransform(old_mob, new_mob))
# old_mob fades out while morphing toward new_mob's shape
# new_mob fades in while morphing from old_mob's shape
Like FadeTransform but aligns submobject families first.
self.play(FadeTransformPieces(old_group, new_group))
VMobject-specific fading that only adjusts stroke/fill opacity (no position change).
self.play(VFadeIn(vmob))
self.play(VFadeOut(vmob))
self.play(VFadeInThenOut(vmob)) # Appears then disappears (rate_func=there_and_back)
Morphs one mobject into the shape/style of another. The original mobject persists (its data changes).
self.play(Transform(mob_a, mob_b))
# After: mob_a looks like mob_b, mob_a is still the scene's mobject
# mob_b is NOT added to the scene
Like Transform, but replaces the original with the target in the scene.
self.play(ReplacementTransform(mob_a, mob_b))
# After: mob_a is removed, mob_b is in the scene
Creates a copy of the source and transforms it into the target. Source stays unchanged.
self.play(TransformFromCopy(mob_a, mob_b))
# After: mob_a unchanged, mob_b is added to scene
Animates a mobject to its .target attribute.
circle.generate_target()
circle.target.shift(RIGHT * 2)
circle.target.set_color(RED)
self.play(MoveToTarget(circle))
Note: mob.animate.method() internally uses this mechanism.
# Old way -- prefer .animate syntax instead
self.play(ApplyMethod(circle.shift, RIGHT * 2))
Apply an arbitrary function to a mobject.
self.play(ApplyFunction(lambda m: m.scale(2).set_color(RED), circle))
Apply a linear transformation matrix.
self.play(ApplyMatrix([[2, 1], [0, 1]], mob)) # 2x2 matrix (extended to 3x3)
self.play(ApplyMatrix(np.eye(3), mob)) # 3x3 identity
Apply a complex function to all points (treating xy-plane as complex plane).
self.play(ApplyComplexFunction(lambda z: z**2, plane))
Animate a mobject back to its saved state.
circle.save_state() # Save current state
self.play(circle.animate.shift(RIGHT * 3).set_color(RED))
self.play(Restore(circle)) # Animate back to saved state
self.play(CyclicReplace(a, b, c)) # a->b's pos, b->c's pos, c->a's pos
self.play(Swap(a, b)) # Swap positions (alias for CyclicReplace)
ScaleInPlace(mob, 2) # Scale by 2 about center
ShrinkToCenter(mob) # Scale to 0
FadeToColor(mob, RED) # Animate color change
The most powerful tool for animating equation changes. Automatically matches identical substrings.
eq1 = Tex("x^2 + y^2 = 1")
eq2 = Tex("x^2 + y^2 = r^2")
self.play(Write(eq1))
self.wait()
self.play(TransformMatchingStrings(eq1, eq2))
# Matching parts ("x^2 + y^2 = ") transform in place
# Non-matching parts ("1" -> "r^2") fade out/in
Force specific substrings to match even if they differ:
self.play(TransformMatchingStrings(
eq1, eq2,
matched_keys=["x^2", "y^2", "="], # These substrings match between eq1 and eq2
))
Map a substring in source to a different substring in target:
eq1 = Tex("a^2 + b^2 = c^2")
eq2 = Tex("x^2 + y^2 = z^2")
self.play(TransformMatchingStrings(
eq1, eq2,
key_map={"a": "x", "b": "y", "c": "z"},
))
Directly specify pairs of submobjects to match:
self.play(TransformMatchingStrings(
eq1, eq2,
matched_pairs=[(eq1[0:3], eq2[0:3])], # Match first 3 chars
))
Matches based on geometric shape similarity (not string content). Works on any mobjects.
self.play(TransformMatchingShapes(group1, group2))
Alias for TransformMatchingStrings.
Temporarily scales up and changes color, then reverts.
self.play(Indicate(mob))
self.play(Indicate(mob, scale_factor=1.5, color=RED))
# Default: scale_factor=1.2, color=YELLOW, rate_func=there_and_back
Creates radiating flash lines at a point.
self.play(Flash(point))
self.play(Flash(mob)) # Flashes at mob's center
self.play(Flash(
point,
color=RED,
line_length=0.3,
num_lines=16,
flash_radius=0.5,
))
Draws a circle around a mobject that appears and disappears.
self.play(CircleIndicate(mob, color=YELLOW))
A stroke flash that traces around the boundary of a mobject.
self.play(FlashAround(mob))
self.play(FlashAround(mob, color=RED, stroke_width=6, time_width=1.0))
Like FlashAround but only underlines.
self.play(FlashUnder(mob))
A partial stroke that travels along a path.
self.play(ShowPassingFlash(path.copy(), time_width=0.3, run_time=2))
Gaussian-width version of ShowPassingFlash (smoother).
self.play(VShowPassingFlash(path.copy(), time_width=0.3, run_time=2))
Sends a wave distortion through a mobject.
self.play(ApplyWave(mob))
self.play(ApplyWave(mob, direction=UP, amplitude=0.3))
self.play(WiggleOutThenIn(mob, scale_value=1.1, rotation_angle=0.02 * TAU))
self.play(ShowCreationThenDestruction(path.copy(), run_time=2))
self.play(ShowCreationThenFadeOut(circle.copy()))
Combines a fade-in with a passing flash outline.
self.play(FlashyFadeIn(vmob, stroke_width=2))
Play multiple animations simultaneously with explicit control.
self.play(AnimationGroup(
FadeIn(a),
FadeIn(b),
FadeIn(c),
lag_ratio=0, # 0 = all simultaneous (default)
))
Play animations one after another within a single self.play().
self.play(Succession(
FadeIn(a),
FadeIn(b),
FadeIn(c),
))
# a fades in, then b, then c
Stagger the start times of animations.
self.play(LaggedStart(
FadeIn(a), FadeIn(b), FadeIn(c),
lag_ratio=0.2, # Each starts 20% into the previous
))
Apply the same animation function to each submobject of a group, with lagged starts.
self.play(LaggedStartMap(FadeIn, group, lag_ratio=0.1))
self.play(LaggedStartMap(Write, equations, lag_ratio=0.3, run_time=4))
self.play(LaggedStartMap(GrowFromCenter, dots, lag_ratio=0.05))
# With additional kwargs passed to each animation
self.play(LaggedStartMap(FadeIn, group, shift=UP, lag_ratio=0.1))
self.play(MoveAlongPath(dot, circle_path, run_time=3))
Apply a continuous deformation (x, y, z, t) -> (x', y', z').
self.play(Homotopy(
lambda x, y, z, t: (x + t, y + t * np.sin(x), z),
mob,
run_time=3,
))
self.play(ComplexHomotopy(
lambda z, t: z * np.exp(1j * t * PI),
plane,
run_time=3,
))
Apply a vector field flow to a mobject.
self.play(PhaseFlow(
lambda p: np.array([-p[1], p[0], 0]),
mob,
run_time=3,
))
self.play(Rotate(mob, angle=PI)) # 180 degrees (default)
self.play(Rotate(mob, angle=TAU, axis=UP)) # Full rotation around Y
self.play(Rotate(mob, angle=90 * DEG))
# Default: rate_func=smooth, run_time=1
Like Rotate but defaults to a full turn with linear rate function and longer run_time.
self.play(Rotating(mob, angle=TAU, run_time=5, rate_func=linear))
Animate a DecimalNumber from its current value to a target.
num = DecimalNumber(0)
self.play(ChangeDecimalToValue(num, 100), run_time=3)
Animate counting from a source number to the current value.
num = DecimalNumber(42)
self.play(CountInFrom(num, 0)) # Counts from 0 up to 42
Most flexible -- provide a function from alpha to value.
self.play(ChangingDecimal(
num,
lambda alpha: alpha * 100, # Goes from 0 to 100
run_time=3,
))
self.play(GrowFromCenter(mob))
self.play(GrowFromPoint(mob, point=ORIGIN))
self.play(GrowFromPoint(mob, point=LEFT * 3, point_color=RED))
self.play(GrowFromEdge(mob, edge=DOWN))
Grows an arrow from its start point.
self.play(GrowArrow(arrow))
Apply a function to a mobject each frame during the animation.
self.play(UpdateFromFunc(
label,
lambda m: m.next_to(dot, UP),
), run_time=3)
Like UpdateFromFunc but the function also receives the animation alpha.
self.play(UpdateFromAlphaFunc(
mob,
lambda m, alpha: m.set_opacity(alpha),
), run_time=2)
Keep a mobject at a fixed offset from another mobject during animation.
self.play(
dot.animate.shift(RIGHT * 3),
MaintainPositionRelativeTo(label, dot),
run_time=2,
)
All animations accept these keyword arguments:
Animation(
mobject,
run_time=1.0, # Duration in seconds
rate_func=smooth, # Easing function
lag_ratio=0, # Stagger submobjects (0=simultaneous, 1=sequential)
remover=False, # Remove mobject from scene after animation?
suspend_mobject_updating=False, # Pause mobject updaters during animation?
)
These can also be passed to self.play() to override for all animations in that call:
self.play(FadeIn(a), FadeIn(b), run_time=2, rate_func=linear)
Specify when during the total run_time an animation should be active:
self.play(
FadeIn(a, time_span=(0, 1)), # Fade in during t=0 to t=1
FadeIn(b, time_span=(1, 2)), # Fade in during t=1 to t=2
FadeIn(c, time_span=(0.5, 1.5)), # Fade in during t=0.5 to t=1.5
run_time=2,
)
This is an alternative to LaggedStart / Succession for fine-grained timing control.