Animations are transformations applied to mobjects over time. ManimVTK provides a rich set of animation classes for creating smooth, beautiful movements and effects.
All animations are played using self.play() in your scene’s construct() method
from manimvtk import *class BasicAnimation(Scene): def construct(self): circle = Circle() # Play a single animation self.play(Create(circle)) # Wait (pause animation) self.wait()
class TransformExample(Scene): def construct(self): circle = Circle() square = Square() self.play(Create(circle)) self.wait() # Transform circle into square self.play(Transform(circle, square)) self.wait()
from manimvtk import LaggedStartshapes = VGroup(*[Circle() for _ in range(5)])shapes.arrange(RIGHT)self.play( LaggedStart(*[Create(s) for s in shapes], lag_ratio=0.2))
# Good - gives viewers time to processself.play(Write(important_equation), run_time=2)self.wait(1)# Too fast - hard to followself.play(Write(important_equation), run_time=0.2)
Group related animations
Copy
# Good - simultaneous related actionsself.play( circle.animate.shift(RIGHT), square.animate.shift(LEFT))# Less effective - sequential when simultaneous makes senseself.play(circle.animate.shift(RIGHT))self.play(square.animate.shift(LEFT))
Use appropriate rate functions
Copy
# Smooth for most animationsself.play(mob.animate.shift(UP), rate_func=smooth)# Linear for constant motionself.play(mob.animate.shift(RIGHT), rate_func=linear)# Rush for dramatic effectself.play(mob.animate.scale(2), rate_func=rush_into)
Use .animate for clarity
Copy
# Preferred - clear and conciseself.play(circle.animate.shift(RIGHT).scale(2))# Avoid - more verboseself.play( ApplyMethod(circle.shift, RIGHT), ApplyMethod(circle.scale, 2))
class BuildUp(Scene): def construct(self): elements = VGroup(*[Square() for _ in range(4)]) elements.arrange(RIGHT, buff=0.5) # Add one at a time for elem in elements: self.play(FadeIn(elem)) self.wait(0.3)