A community-maintained Python framework for creating mathematical animations.
FadeInAndShiftFromDirection -> FadeInFrom
Grant Sanderson10850c5af688
diff --git a/manimlib/animation/animation.py b/manimlib/animation/animation.pyindex c8e354042..fad9bd360 100644--- a/manimlib/animation/animation.py+++ b/manimlib/animation/animation.py@@ -34,8 +34,10 @@ class Animation(object):return self.__class__.__name__ + str(self.mobject)def begin(self):- # As much initialization as possible, especially any- # mobject copying, should live in this method+ # This is called right as an animation is being+ # played. As much initialization as possible,+ # especially any mobject copying, should live in+ # this methodmobject = self.mobject# Keep track of where it startedself.starting_mobject = mobject.copy()diff --git a/manimlib/animation/fading.py b/manimlib/animation/fading.pyindex 2eff0f96d..c57589be8 100644--- a/manimlib/animation/fading.py+++ b/manimlib/animation/fading.py@@ -3,7 +3,6 @@ from manimlib.animation.transform import Transformfrom manimlib.constants import *from manimlib.mobject.types.vectorized_mobject import VMobjectfrom manimlib.utils.bezier import interpolate-from manimlib.utils.config_ops import digest_configclass FadeOut(Transform):@@ -11,10 +10,8 @@ class FadeOut(Transform):"remover": True,}- def __init__(self, mobject, **kwargs):- target = mobject.copy()- target.fade(1)- Transform.__init__(self, mobject, target, **kwargs)+ def create_target(self):+ return self.mobject.copy().fade(1)def clean_up_from_scene(self, scene=None):Transform.clean_up_from_scene(self, scene)@@ -22,39 +19,40 @@ class FadeOut(Transform):class FadeIn(Transform):- def __init__(self, mobject, **kwargs):- target = mobject.copy()- Transform.__init__(self, mobject, target, **kwargs)+ def create_target(self):+ return self.mobject++ def begin(self):+ super().begin()self.starting_mobject.fade(1)if isinstance(self.starting_mobject, VMobject):self.starting_mobject.set_stroke(width=0)self.starting_mobject.set_fill(opacity=0)-class FadeInAndShiftFromDirection(Transform):+class FadeInFrom(Transform):CONFIG = {"direction": DOWN,}def __init__(self, mobject, direction=None, **kwargs):- digest_config(self, kwargs)- target = mobject.copy()- if direction is None:- direction = self.direction- mobject.shift(direction)- mobject.fade(1)- Transform.__init__(self, mobject, target, **kwargs)+ if direction is not None:+ self.direction = direction+ Transform.__init__(self, mobject, **kwargs)+ def create_target(self):+ return self.mobject.copy()-class FadeInFrom(FadeInAndShiftFromDirection):- """- Alternate name for FadeInAndShiftFromDirection- """+ def begin(self):+ super().begin()+ self.starting_mobject.shift(self.direction)+ self.starting_mobject.fade(1)-class FadeInFromDown(FadeInAndShiftFromDirection):+class FadeInFromDown(FadeInFrom):"""- Essential a more convenient form of FadeInAndShiftFromDirection+ Identical to FadeInFrom, just with a name that+ communicates the default"""CONFIG = {"direction": DOWN,diff --git a/old_projects/alt_calc.py b/old_projects/alt_calc.pyindex 2b477d759..13d4ec8b6 100644--- a/old_projects/alt_calc.py+++ b/old_projects/alt_calc.py@@ -2858,7 +2858,7 @@ class RepeatedApplicationGraphically(GraphOnePlusOneOverX, PiCreatureScene):dot = Dot(color=RED, fill_opacity=0.7)dot.move_to(self.coords_to_point(x_val, curr_output))- self.play(FadeInAndShiftFromDirection(dot, 2 * UR))+ self.play(FadeInFrom(dot, 2 * UR))self.wait()for n in range(self.n_jumps):@@ -2955,7 +2955,7 @@ class AnalyzeFunctionWithTransformations(NumberlineTransformationScene):sample_points = list(map(Mobject.get_center, sample_dots))self.play(OldLaggedStart(- FadeInAndShiftFromDirection, sample_dots,+ FadeInFrom, sample_dots,lambda m: (m, UP)))self.show_arrows(sample_points)diff --git a/old_projects/dandelin.py b/old_projects/dandelin.pyindex 3786e7569..0bf1e3986 100644--- a/old_projects/dandelin.py+++ b/old_projects/dandelin.py@@ -67,7 +67,7 @@ class ThinkingAboutAProof(PiCreatureScene):self.add(bubble)self.play(- FadeInAndShiftFromDirection(you, LEFT),+ FadeInFrom(you, LEFT),GrowArrow(you_arrow),)self.play(@@ -222,7 +222,7 @@ class MultipleDefinitionsOfAnEllipse(Scene):definition.saved_state.set_fill(LIGHT_GREY, 0.5)self.play(OldLaggedStart(- FadeInAndShiftFromDirection, definitions,+ FadeInFrom, definitions,lambda m: (m, RIGHT),run_time=4))@@ -293,7 +293,7 @@ class StretchACircle(Scene):self.play(GrowArrow(xy_arrow),Write(xy),- FadeInAndShiftFromDirection(start_point, UP),+ FadeInFrom(start_point, UP),)self.wait()self.add(circle_ghost)@@ -869,7 +869,7 @@ class ShowMeasurementBook(TeacherStudentsScene):self.wait()self.play(GrowArrow(arrow),- FadeInAndShiftFromDirection(words, RIGHT),+ FadeInFrom(words, RIGHT),self.get_student_changes("thinking", "happy", "pondering",look_at_arg=arrowdiff --git a/old_projects/div_curl.py b/old_projects/div_curl.pyindex 59645f174..71ab0ecc9 100644--- a/old_projects/div_curl.py+++ b/old_projects/div_curl.py@@ -2493,7 +2493,7 @@ class ShearCurl(IntroduceCurl):start_up_time=8,)- self.play(FadeInAndShiftFromDirection(twig, UP))+ self.play(FadeInFrom(twig, UP))self.add(twig_rotation)self.wait(16)@@ -3896,7 +3896,7 @@ class DivergenceTinyNudgesView(MovingCameraScene):)self.add_foreground_mobjects(input_dot)self.play(- FadeInAndShiftFromDirection(input_dot, SMALL_BUFF * DL),+ FadeInFrom(input_dot, SMALL_BUFF * DL),Write(input_words),)self.play(@@ -4199,13 +4199,13 @@ class DivergenceTinyNudgesView(MovingCameraScene):dot_product.fade, 1,remover=True)- self.play(FadeInAndShiftFromDirection(cross_product, sf * DOWN))+ self.play(FadeInFrom(cross_product, sf * DOWN))self.play(div_text.shift, sf * DOWN,div_text.fade, 1,remover=True)- self.play(FadeInAndShiftFromDirection(curl_text, sf * DOWN))+ self.play(FadeInFrom(curl_text, sf * DOWN))self.wait()def rotate_difference_vectors(self):@@ -4633,7 +4633,7 @@ class ThoughtsOnAds(Scene):self.play(FadeIn(left_text),- FadeInAndShiftFromDirection(knob, 2 * RIGHT)+ FadeInFrom(knob, 2 * RIGHT))self.wait()self.play(diff --git a/old_projects/lost_lecture.py b/old_projects/lost_lecture.pyindex f7f5b0f90..af2a3670a 100644--- a/old_projects/lost_lecture.py+++ b/old_projects/lost_lecture.py@@ -184,7 +184,7 @@ class ShowEmergingEllipse(Scene):self.play(ShowCreation(circle))self.play(- FadeInAndShiftFromDirection(e_dot, LEFT),+ FadeInFrom(e_dot, LEFT),Write(eccentric_words, run_time=1))self.wait()@@ -1226,7 +1226,7 @@ class ShowEllipseDefiningProperty(Scene):self.add_foreground_mobjects(push_pins, dot)self.add(dot_update)self.play(OldLaggedStart(- FadeInAndShiftFromDirection, push_pins,+ FadeInFrom, push_pins,lambda m: (m, 2 * UP + LEFT),run_time=1,lag_ratio=0.75@@ -2760,7 +2760,7 @@ class FeynmanRecountingNewton(Scene):)self.wait()self.play(*[- FadeInAndShiftFromDirection(+ FadeInFrom(mob, direction=3 * LEFT)for mob in (principia, principia.rect)diff --git a/old_projects/quaternions.py b/old_projects/quaternions.pyindex 44b51ed36..11f050598 100644--- a/old_projects/quaternions.py+++ b/old_projects/quaternions.py@@ -1882,7 +1882,7 @@ class WalkThroughComplexMultiplication(ShowComplexMultiplicationExamples):self.add(product[:-1])self.play(ReplacementTransform(w_label[1][0].copy(), w_sym),- FadeInAndShiftFromDirection(product[2], LEFT),+ FadeInFrom(product[2], LEFT),FadeIn(product[0]),)self.wait()diff --git a/old_projects/wallis.py b/old_projects/wallis.pyindex 3f8aebc00..433d1cc2e 100644--- a/old_projects/wallis.py+++ b/old_projects/wallis.py@@ -2061,7 +2061,7 @@ class PlugObserverIntoPolynomial(DistanceProductScene):]self.play(- FadeInAndShiftFromDirection(observer, direction=-vect),+ FadeInFrom(observer, direction=-vect),GrowArrow(arrow))self.play(Write(full_name))@@ -4167,7 +4167,7 @@ class HowThisArgumentRequiresCommunitingLimits(PiCreatureScene):self.play(OldLaggedStart(GrowArrow, fraction_limit_arrows),OldLaggedStart(- FadeInAndShiftFromDirection, fraction_limits,+ FadeInFrom, fraction_limits,direction=UP),run_time=4,@@ -4181,7 +4181,7 @@ class HowThisArgumentRequiresCommunitingLimits(PiCreatureScene):)self.play(GrowArrow(result_limit_arrow),- FadeInAndShiftFromDirection(result_limit, direction=UP),+ FadeInFrom(result_limit, direction=UP),morty.change, "confused",)self.wait(2)@@ -4447,7 +4447,7 @@ class DelicacyInIntermixingSeries(Scene):for product in products:self.play(GrowArrow(product.arrow),- FadeInAndShiftFromDirection(product.limit, direction=LEFT)+ FadeInFrom(product.limit, direction=LEFT))self.wait()self.play(@@ -4518,7 +4518,7 @@ class DelicacyInIntermixingSeries(Scene):)self.play(GrowArrow(new_arrow),- FadeInAndShiftFromDirection(new_limit, LEFT),+ FadeInFrom(new_limit, LEFT),bottom_product.parts[3:].fade, 1,)self.play(FadeIn(randy))@@ -4801,7 +4801,7 @@ class KeeperAndSailorForSineProduct(KeeperAndSailor):self.play(OldLaggedStart(GrowArrow, limit_arrows),OldLaggedStart(- FadeInAndShiftFromDirection, limits,+ FadeInFrom, limits,lambda m: (m, UP),),OldLaggedStart(FadeIn, dots)