A community-maintained Python framework for creating mathematical animations.
Cleaned up specialized animations
Grant Sanderson05c7196a6f1d
diff --git a/manimlib/animation/specialized.py b/manimlib/animation/specialized.pyindex 122b4a551..c4f5457d9 100644--- a/manimlib/animation/specialized.py+++ b/manimlib/animation/specialized.py@@ -1,6 +1,10 @@-from manimlib.animation.composition import OldLaggedStart+import operator as op++from manimlib.animation.composition import LaggedStartfrom manimlib.animation.transform import ApplyMethod-from manimlib.constants import *+from manimlib.animation.transform import Restore+from manimlib.constants import WHITE+from manimlib.constants import BLACKfrom manimlib.mobject.geometry import Circlefrom manimlib.mobject.svg.drawings import Carfrom manimlib.mobject.types.vectorized_mobject import VGroup@@ -11,13 +15,25 @@ from manimlib.utils.space_ops import get_normclass MoveCar(ApplyMethod):CONFIG = {"moving_forward": True,+ "run_time": 5,}def __init__(self, car, target_point, **kwargs):- assert isinstance(car, Car)- ApplyMethod.__init__(self, car.move_to, target_point, **kwargs)- displacement = self.target_mobject.get_right() - self.starting_mobject.get_right()- distance = get_norm(displacement)+ self.check_if_input_is_car(car)+ self.target_point = target_point+ super().__init__(car.move_to, target_point, **kwargs)++ def check_if_input_is_car(self, car):+ if not isinstance(car, Car):+ raise Exception("MoveCar must take in Car object")++ def begin(self):+ super().begin()+ car = self.mobject+ distance = get_norm(op.sub(+ self.target_mobject.get_right(),+ self.starting_mobject.get_right(),+ ))if not self.moving_forward:distance *= -1tire_radius = car.get_tires()[0].get_width() / 2@@ -32,7 +48,7 @@ class MoveCar(ApplyMethod):tire.rotate_in_place(radians)-class Broadcast(OldLaggedStart):+class Broadcast(LaggedStart):CONFIG = {"small_radius": 0.0,"big_radius": 5,@@ -40,7 +56,7 @@ class Broadcast(OldLaggedStart):"start_stroke_width": 8,"color": WHITE,"remover": True,- "lag_ratio": 0.7,+ "lag_ratio": 0.2,"run_time": 3,"remover": True,}@@ -54,13 +70,15 @@ class Broadcast(OldLaggedStart):stroke_color=BLACK,stroke_width=0,)- circle.move_to(focal_point)+ circle.add_updater(+ lambda c: c.move_to(focal_point)+ )circle.save_state()circle.set_width(self.small_radius * 2)circle.set_stroke(self.color, self.start_stroke_width)circles.add(circle)- OldLaggedStart.__init__(- self, ApplyMethod, circles,- lambda c: (c.restore,),- **kwargs- )+ animations = [+ Restore(circle)+ for circle in circles+ ]+ super().__init__(*animations, **kwargs)