From 2a711a37f8bb7581a742bae0e154ee3d3aff5434 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Mon, 21 Mar 2016 19:29:12 -0700 Subject: [PATCH] MoveAlongPath animation --- animation/simple_animations.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/animation/simple_animations.py b/animation/simple_animations.py index f8ff7bff..9bf53c2f 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):