A community-maintained Python framework for creating mathematical animations.
Added/tweaked some indication animations
Grant Sanderson99d119e1f6ec
diff --git a/animation/indication.py b/animation/indication.pyindex 5a6f1d4e5..c22bdd91d 100644--- a/animation/indication.py+++ b/animation/indication.py@@ -6,14 +6,21 @@ from constants import *from animation.animation import Animationfrom animation.movement import Homotopy+from animation.composition import AnimationGroup+from animation.composition import Succession+from animation.creation import ShowCreationfrom animation.creation import ShowPartial+from animation.creation import FadeOutfrom animation.transform import Transformfrom mobject.mobject import Mobjectfrom mobject.geometry import Circlefrom mobject.geometry import Dot+from mobject.shape_matchers import SurroundingRectangle+from utils.bezier import interpolatefrom utils.config_ops import digest_configfrom utils.rate_functions import squish_rate_funcfrom utils.rate_functions import there_and_back+from utils.rate_functions import wiggleclass FocusOn(Transform):@@ -93,14 +100,49 @@ class ShowCreationThenDestruction(ShowPassingFlash):}+class AnimationOnSurroundingRectangle(AnimationGroup):+ CONFIG = {+ "surrounding_rectangle_config": {},+ # Function which takes in a rectangle, and spits+ # out some animation. Could be some animation class,+ # could be something more+ "rect_to_animation": Animation+ }++ def __init__(self, mobject, **kwargs):+ digest_config(self, kwargs)+ rect = SurroundingRectangle(+ mobject, **self.surrounding_rectangle_config+ )+ AnimationGroup.__init__(self, self.rect_to_animation(rect, **kwargs))+++class ShowPassingFlashAround(AnimationOnSurroundingRectangle):+ CONFIG = {+ "rect_to_animation": ShowPassingFlash+ }+++class ShowCreationThenDestructionAround(AnimationOnSurroundingRectangle):+ CONFIG = {+ "rect_to_animation": ShowCreationThenDestruction+ }+++class CircleThenFadeAround(AnimationOnSurroundingRectangle):+ CONFIG = {+ "rect_to_animation": lambda rect: Succession(+ ShowCreation, rect,+ FadeOut, rect,+ )+ }++class ApplyWave(Homotopy):CONFIG = {- "direction": DOWN,+ "direction": UP,"amplitude": 0.2,"run_time": 1,- "apply_function_kwargs": {- "maintain_smoothness": False,- },}def __init__(self, mobject, **kwargs):@@ -110,9 +152,9 @@ class ApplyWave(Homotopy):vect = self.amplitude * self.directiondef homotopy(x, y, z, t):- start_point = np.array([x, y, z])alpha = (x - left_x) / (right_x - left_x)- power = np.exp(2 * (alpha - 0.5))+ # lf = self.lag_factor+ power = np.exp(2.0 * (alpha - 0.5))nudge = there_and_back(t**power)return np.array([x, y, z]) + nudge * vectHomotopy.__init__(self, homotopy, mobject, **kwargs)@@ -195,7 +237,6 @@ class TurnInsideOut(Transform):}def __init__(self, mobject, **kwargs):- mobject.sort_points(np.linalg.norm)mob_copy = mobject.copy()- mob_copy.sort_points(lambda p: -np.linalg.norm(p))+ mob_copy.reverse_points()Transform.__init__(self, mobject, mob_copy, **kwargs)