Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

MoveAlongPath animation

Grant Sanderson2a711a37f8bb
diff --git a/animation/simple_animations.py b/animation/simple_animations.py
index f8ff7bffd..9bf53c2f9 100644
--- a/animation/simple_animations.py
+++ b/animation/simple_animations.py
@@ -126,6 +126,16 @@ class PhaseFlow(Animation):
)
self.last_alpha = alpha
+class MoveAlongPath(Animation):
+ def __init__(self, mobject, path, **kwargs):
+ digest_config(self, kwargs, locals())
+ Animation.__init__(self, mobject, **kwargs)
+
+ def update_mobject(self, alpha):
+ n = self.path.get_num_points()-1
+ point = self.path.points[int(alpha*n)]
+ self.mobject.shift(point-self.mobject.get_center())
+
### Animation modifiers ###
class ApplyToCenters(Animation):