Reference: Animations and Rate Functions
Every animation and rate function.
Bringing things in and out
A rate function is how an animation speeds up and slows down. Every animation also takes run_time (seconds, usually 1), rate_func and lag_ratio. See Animations for a guide.
Create(mobject): Draws the outline as if with a pen, from its start.ShowCreation(mobject): The older name ofCreate.Uncreate(mobject):Createbackwards; then it is gone.Write(mobject): Writes text or maths a stroke at a time (1 s, or 2 for long ones).Unwrite(mobject):Writebackwards; then it is gone.DrawBorderThenFill(mobject): Draws the outline, then fills the inside (2 s).FadeIn(*mobjects, shift=None, target_position=None, scale=1): Fades in;shift=UPslides it in,scale=0.5grows it from half size.FadeOut(*mobjects, shift=None, target_position=None, scale=1): Fades out;shift=DOWNslides it away; then it is gone.GrowFromCenter(mobject): Grows from nothing at its middle.GrowFromPoint(mobject, point): Grows from nothing at a point.GrowFromEdge(mobject, edge): Grows from one side (DOWN,LEFT…).GrowArrow(mobject): Grows an arrow from its tail.SpinInFromNothing(mobject): Grows while turning.ShrinkToCenter(mobject): Shrinks to nothing at its middle.AddTextLetterByLetter(text, suspend_mobject_updating=False, int_func=None, rate_func=linear, time_per_char=0.1, reverse_rate_function=False, introducer=True): Types text out a letter at a time (time_per_chareach).RemoveTextLetterByLetter(text, suspend_mobject_updating=False, int_func=None, rate_func=linear, time_per_char=0.1, reverse_rate_function=False, introducer=True): Removes text a letter at a time, from the end.ShowIncreasingSubsets(mobject): Shows the members of a group one more at a time, keeping the earlier ones.ShowSubmobjectsOneByOne(mobject): Shows the members of a group one at a time, only one at once.
Changing things
Transform(mobject, target_mobject=None, path_arc=0): Changes one object until it looks like another; the first stays on screen.ReplacementTransform(mobject, target_mobject=None, path_arc=0): AsTransform, but the second object is the one on screen afterwards.TransformFromCopy(mobject, target_mobject=None, path_arc=0): A copy of the first changes into the second; the first stays.TransformMatchingTex(mobject, target_mobject=None, path_arc=0): Equation parts with the same TeX move to their new places; the rest fade.TransformMatchingShapes(mobject, target_mobject=None, path_arc=0): Pieces with the same shape move to their new places; the rest fade.FadeTransform(mobject, target_mobject, stretch=True, dim_to_match=1): Cross-fades one object into another while moving it into place.FadeTransformPieces(mobject, target_mobject, stretch=True, dim_to_match=1):FadeTransformmember by member.MoveToTarget(mobject): Plays the changes made tom.target(aftergenerate_target).Restore(mobject): Goes back to how it looked atsave_state.ApplyMethod(method): Plays a method's change:ApplyMethod(m.shift, UP).ApplyFunction(function, mobject): Plays a function's change:ApplyFunction(lambda m: m.scale(2), m).ApplyPointwiseFunction(function, mobject, run_time=3): Moves every point of the outline through a function of the point.ApplyMatrix(matrix, mobject, about_point=ORIGIN): Moves every point by a matrix, such as[[1, 1], [0, 1]](a shear).Homotopy(homotopy, mobject, run_time=3, apply_function_kwargs=None): Moves every point through a function of(x, y, z, t)astgoes from 0 to 1.ScaleInPlace(mobject, scale_factor): Scales about its middle; the same as.animate.scale.ChangeDecimalToValue(decimal_mob, target_number): Counts aDecimalNumberto a new value.ChangingDecimal(decimal_mob, number_update_func, suspend_mobject_updating=False): Sets aDecimalNumberfrom a function of the animation's progress (0 to 1).
from pymations import *
a = MathTex("x", "+", "3", "=", "5")
b = MathTex("x", "=", "5", "-", "3")
play(Write(a))
play(TransformMatchingTex(a, b))
Moving and turning
Rotate(mobject, angle=PI, axis=OUT, about_point=None): Turns it byangleabout its middle (orabout_point).Rotating(mobject, axis=OUT, radians=TAU, about_point=None, about_edge=None, run_time=5, rate_func=linear): A steady full turn over 5 s.MoveAlongPath(mobject, path): Moves it along a line or curve.Swap(*mobjects, path_arc=90 * DEGREES): Two objects swap places along arcs.CyclicReplace(*mobjects, path_arc=90 * DEGREES): Each object moves to the next one's place along an arc.
Drawing attention
Indicate(mobject): Grows a little and turns yellow, then goes back.Circumscribe(mobject): Runs a line once round it.Flash(point, line_length=0.2, num_lines=12, flash_radius=0.1, line_stroke_width=3, color=YELLOW, time_width=1): Short lines burst out from a point.ShowPassingFlash(mobject): A short piece of the outline runs along it, then is gone.Wiggle(mobject): Wiggles it (2 s).ApplyWave(mobject, direction=UP, amplitude=0.2, wave_func=smooth, time_width=1, ripples=1, run_time=2): A wave passes through it.Blink(mobject, time_on=0.5, time_off=0.5, blinks=1, hide_at_end=False): Hides and shows it,blinkstimes.FocusOn(focus_point, opacity=0.2, color=GREY, run_time=2): A spotlight closes in on a point.Broadcast(mobject, focal_point=ORIGIN, n_mobs=5, initial_opacity=1, final_opacity=0, initial_width=0.0, remover=True, lag_ratio=0.2, run_time=3): Rings spread out from a point.
Timing and groups
Wait(run_time=1): A pause, as an animation (for use inside groups).AnimationGroup(*animations, group=None): Plays animations together, as one animation.Succession(*animations, group=None): Plays animations one after another.LaggedStart(*animations, group=None): Starts each animation a little after the one before (lag_ratio, 0.05 unless you say).LaggedStartMap(AnimationClass, mobject, arg_creator=None, run_time=2):LaggedStartof one animation over every member of a group (2 s).ChangeSpeed(anim, speedinfo, affects_speed_updaters=True): Plays another animation faster or slower in parts:speedinfo={0.5: 2}doubles the speed from halfway.Animation(mobject): The base of every animation; all of them takerun_time,rate_funcandlag_ratio..run_time: How long it lasts, in seconds..set_run_time(run_time): Sets how long it lasts..set_rate_func(rate_func): Sets how it speeds up and slows down.
from pymations import *
dots = VGroup(*[Dot() for _ in range(5)]).arrange(RIGHT)
play(LaggedStart(*[GrowFromCenter(d) for d in dots], lag_ratio=0.3), run_time=2, rate_func=linear)
Rate functions
Give one as rate_func= to an animation or to play. Each takes the progress t, from 0 to 1.
linear: Steady from start to end.smooth: Starts and ends gently (the usual one).smoothstep: A gentler start and end, a simple S-curve.smootherstep: An even gentler S-curve.smoothererstep: The gentlest S-curve.rush_into: Starts gently, ends fast.rush_from: Starts fast, ends gently.slow_into: Slows down as it arrives.double_smooth: Two gentle halves, pausing in the middle.there_and_back: Goes and comes back.there_and_back_with_pause: Goes, waits, and comes back.running_start: Backs up a little first, then goes.wiggle: Wobbles back and forth and ends where it started.lingering: Arrives early and stays.exponential_decay: Fast at first, then settles.ease_in_sine: Standard easing: slow start.ease_out_sine: Standard easing: slow end.ease_in_out_sine: Standard easing: slow start and end.ease_in_quad: Slow start (stronger than sine).ease_out_quad: Slow end (stronger than sine).ease_in_out_quad: Slow start and end (stronger than sine).ease_in_cubic: Slow start (stronger).ease_out_cubic: Slow end (stronger).ease_in_out_cubic: Slow start and end (stronger).ease_in_quart: Slow start (stronger still).ease_out_quart: Slow end (stronger still).ease_in_out_quart: Slow start and end (stronger still).ease_in_quint: Very slow start.ease_out_quint: Very slow end.ease_in_out_quint: Very slow start and end.ease_in_expo: Almost still, then fast.ease_out_expo: Fast, then almost still.ease_in_out_expo: Almost still at both ends, fast in the middle.ease_in_circ: Slow start along a circle curve.ease_out_circ: Slow end along a circle curve.ease_in_out_circ: Slow start and end along a circle curve.ease_in_back: Backs up a little, then goes.ease_out_back: Overshoots a little, then settles.ease_in_out_back: Backs up at the start and overshoots at the end.ease_in_elastic: Wobbles like a spring, then goes.ease_out_elastic: Goes, then wobbles like a spring into place.ease_in_out_elastic: Springy at both ends.ease_in_bounce: Bounces before it goes.ease_out_bounce: Bounces into place.ease_in_out_bounce: Bounces at both ends.