A community-maintained Python framework for creating mathematical animations.
Added Fading example and removed Fade methods (deprecation) (#827)
kolibril132657229c48d3
diff --git a/manim/animation/fading.py b/manim/animation/fading.pyindex 0871206dc..018b4fdcb 100644--- a/manim/animation/fading.py+++ b/manim/animation/fading.py@@ -1,13 +1,63 @@-"""Fading in and out of view."""+"""Fading in and out of view.++.. manim:: Example+ :hide_source:++ class Example(Scene):+ def construct(self):+ s1 = Square().set_color(BLUE)+ s2 = Square().set_color(BLUE)+ s3 = Square().set_color(BLUE)+ s4 = Square().set_color(BLUE)+ s5 = Square().set_color(BLUE)+ s6 = Square().set_color(RED)+ s7 = Square().set_color(RED)+ s8 = Square().set_color(RED)+ VGroup(s1, s2, s3, s4).set_x(0).arrange(buff=1.9).shift(UP)+ VGroup(s5, s6, s7, s8).set_x(0).arrange(buff=1.9).shift(2 * DOWN)+ t1 = Text("FadeIn").scale(0.5).next_to(s1, UP)+ t2 = Text("FadeInFromPoint").scale(0.5).next_to(s2, UP)+ t3 = Text("FadeInFrom").scale(0.5).next_to(s3, UP)+ t4 = Text("VFadeIn").scale(0.5).next_to(s4, UP)+ t5 = Text("FadeInFromLarge").scale(0.4).next_to(s5, UP)+ t6 = Text("FadeOut").scale(0.45).next_to(s6, UP)+ t7 = Text("FadeOutAndShift").scale(0.45).next_to(s7, UP)+ t8 = Text("VFadeOut").scale(0.45).next_to(s8, UP)++ objs = [ManimBanner().scale(0.25) for _ in range(1, 9)]+ objs[0].move_to(s1.get_center())+ objs[1].move_to(s2.get_center())+ objs[2].move_to(s3.get_center())+ objs[3].move_to(s4.get_center())+ objs[4].move_to(s5.get_center())+ objs[5].move_to(s6.get_center())+ objs[6].move_to(s7.get_center())+ objs[7].move_to(s8.get_center())+ self.add(s1, s2, s3, s4, s5, s6, s7, s8, t1, t2, t3, t4, t5, t6, t7, t8)+ self.add(*objs)++ self.play(+ FadeIn(objs[0]),+ FadeInFromPoint(objs[1], s2.get_center()),+ FadeInFrom(objs[2], LEFT*0.2),+ VFadeIn(objs[3]),+ FadeInFromLarge(objs[4]),+ )+ self.wait(0.3)+ self.play(+ FadeOut(objs[5]),+ FadeOutAndShift(objs[6], DOWN),+ VFadeOut(objs[7])+ )++"""__all__ = ["FadeOut","FadeIn","FadeInFrom",- "FadeInFromDown","FadeOutAndShift",- "FadeOutAndShiftDown","FadeInFromPoint","FadeInFromLarge","VFadeIn",@@ -35,30 +85,7 @@ DEFAULT_FADE_LAG_RATIO: float = 0class FadeOut(Transform):- """A transform fading out the given mobject.-- Examples- ---------- .. manim:: PlaneFadeOut-- class PlaneFadeOut(Scene):- def construct(self):- sq1 = Square()- sq2 = Square()- sq3 = Square()- sq1.next_to(sq2, LEFT)- sq3.next_to(sq2, RIGHT)- circ = Circle()- circ.next_to(sq2, DOWN)-- self.add(sq1, sq2, sq3, circ)- self.wait()-- self.play(FadeOut(sq1), FadeOut(sq2), FadeOut(sq3))- self.wait()-- """+ """A transform fading out the given mobject."""def __init__(self,@@ -111,21 +138,6 @@ class FadeInFrom(Transform):self.starting_mobject.fade(1)-class FadeInFromDown(FadeInFrom):- """- Identical to FadeInFrom, just with a name that- communicates the default- """-- def __init__(- self, mobject: "Mobject", direction: np.ndarray = DOWN, **kwargs- ) -> None:- super().__init__(mobject, direction=direction, **kwargs)- logger.warning(- "FadeInFromDown is deprecated and will eventually disappear. Please use FadeInFrom(<mobject>, direction=DOWN, <other_args>) instead."- )--class FadeOutAndShift(FadeOut):def __init__(self, mobject: "Mobject", direction: np.ndarray = DOWN, **kwargs@@ -139,21 +151,6 @@ class FadeOutAndShift(FadeOut):return target-class FadeOutAndShiftDown(FadeOutAndShift):- """- Identical to FadeOutAndShift, just with a name that- communicates the default- """-- def __init__(- self, mobject: "Mobject", direction: np.ndarray = DOWN, **kwargs- ) -> None:- super().__init__(mobject, direction=direction, **kwargs)- logger.warning(- "FadeOutAndShiftDown is deprecated and will eventually disappear. Please use FadeOutAndShift(<mobject>, direction=DOWN, <other_args>) instead."- )--class FadeInFromPoint(FadeIn):def __init__(self, mobject: "Mobject", point: typing.Union["Mobject", np.ndarray], **kwargsdiff --git a/tests/control_data/graphical_units_data/creation/FadeInFromDownTest.npz b/tests/control_data/graphical_units_data/creation/FadeInFromDownTest.npzdeleted file mode 100644index 85ee31861..000000000Binary files a/tests/control_data/graphical_units_data/creation/FadeInFromDownTest.npz and /dev/null differdiff --git a/tests/test_graphical_units/test_creation.py b/tests/test_graphical_units/test_creation.pyindex c7c1e1bed..240764a79 100644--- a/tests/test_graphical_units/test_creation.py+++ b/tests/test_graphical_units/test_creation.py@@ -46,12 +46,6 @@ class FadeInFromTest(Scene):self.play(FadeInFrom(square, direction=UP))-class FadeInFromDownTest(Scene):- def construct(self):- square = Square()- self.play(FadeInFromDown(square))--class FadeOutAndShiftTest(Scene):def construct(self):square = Square()