Movement
The defined movement
Animation in movement.py
- movement.Homotopy(Animation)
- movement.SmoothedVectorizedHomotopy(Homotopy)
- movement.ComplexHomotopy(Homotopy)
- movement.PhaseFlow(Animation)
- movement.MoveAlongPath(Animation)
Class PhaseFlow(Animation)
Homotopy is used to transform both the position and dimension of the specified
VMobject animatedly according to the specified function for given parameters.
Class MoveAlongPath(Animation)
SmoothedVectorizedHomotopy is used to move the specified
VMobject animatedly along the specified path for given parameters.
Example
Code
# folder/file: tut/manim_animation_phaseflowmovealongpath_001a.py
from manimlib.scene.scene import Scene
from manimlib.mobject.geometry import Circle, Square
from manimlib.mobject.svg.tex_mobject import TextMobject
from manimlib.animation.composition import AnimationGroup
from manimlib.animation.creation import ShowCreation, AddTextWordByWord, Write
from manimlib.animation.movement import Homotopy, PhaseFlow, MoveAlongPath
class manim_animation_phaseflowmovealongpath_001a(Scene):
def construct(self):
a1=TextMobject("\\textbf{Test1 Text}",height=0.4).move_to([-4.5,2.5,0])
a2=TextMobject("\\textbf{T2 Text}",height=0.4).move_to([1,2.5,0])
a3=Circle(color="#FFFFFF").scale(0.4).move_to([4,2.5,0])
a4=Square(fill_color="#00FF00",fill_opacity=1).scale(0.4).move_to([6,2.5,0])
b1=TextMobject("\\textbf{Test1 Text}",height=0.2).move_to([-4.5,-0.5,0])
b2=TextMobject("\\textbf{T2 Text}",height=0.4).move_to([1,0.5,0])
b3=Circle(color="#FFFFFF").scale(0.4).move_to([4,0,0])
b4=Square(fill_color="#00FF00",fill_opacity=1).scale(0.2).move_to([5,0.5,0])
c1=TextMobject("\\textbf{Test1 Text}",height=0.4).move_to([-4.5,-2.5,0])
c2=TextMobject("\\textbf{T2 Text}",height=0.4).move_to([1,-2.5,0])
c3=Circle(color="#FFFFFF").scale(0.4).move_to([4,-2.5,0])
c4=Square(fill_color="#00FF00",fill_opacity=1).scale(0.2).move_to([6,-2.5,0])
self.add(a1,a2,a3,a4,b1,b2,b3,b4,c1,c2,c3,c4)
self.add(TextMobject("Homotopy").set_color("FF3300").move_to([0,3.5,0]),TextMobject("PhaseFlow").set_color("888888").move_to([0,1,0]),TextMobject("MoveAlongPath").set_color("33FF00").move_to([0,-1.5,0]))
self.wait(3)
def funcphase(t): return t*0.25*([1,1,0])
def funchomotopy(x,y,z,t): return (x+t*0.25,y+t*0.25,z)
self.play(AnimationGroup(Homotopy(funchomotopy, a1.copy().set_color("FF3300")),PhaseFlow(funcphase, b1.copy().set_color("888888")),MoveAlongPath(c1.copy().set_color("33FF00"),c3)),run_time=5)
self.wait(3)
self.play(AnimationGroup(Homotopy(funchomotopy, a2.copy().set_color("FF3300")),PhaseFlow(funcphase, b2.copy().set_color("888888")),MoveAlongPath(c2.copy().set_color("33FF00"),c4)),run_time=5)
self.wait(3)
self.play(AnimationGroup(Homotopy(funchomotopy, a3.copy().set_color("FF3300")),PhaseFlow(funcphase, b3.copy().set_color("888888")),MoveAlongPath(c3.copy().set_color("33FF00"),c1[0][0])),run_time=5)
self.wait(3)
self.play(AnimationGroup(Homotopy(funchomotopy, a4.copy().set_color("FF3300")),PhaseFlow(funcphase, b4.copy().set_color("888888")),MoveAlongPath(c4.copy().set_color("33FF00"),c2[0][0])),run_time=5)
self.wait(3)
Output