A community-maintained Python framework for creating mathematical animations.
Added example to demonstrate differences between :class:`~.Transform` and :class:`~.ReplacementTransform` (#1569)
Vagride24b789c9006
diff --git a/manim/animation/transform.py b/manim/animation/transform.pyindex 00d85b1e0..ca3f304a9 100644--- a/manim/animation/transform.py+++ b/manim/animation/transform.py@@ -144,6 +144,53 @@ class Transform(Animation):class ReplacementTransform(Transform):+ """Replaces and morphs a mobject into a target mobject.++ Parameters+ ----------+ mobject+ The starting :class:`~.Mobject`.+ target_mobject+ The target :class:`~.Mobject`.+ kwargs+ Further keyword arguments that are passed to :class:`Transform`.++ Examples+ --------++ .. manim:: ReplacementTransformOrTransform+ :quality: low++ class ReplacementTransformOrTransform(Scene):+ def construct(self):+ # set up the numbers+ r_transform = VGroup(*[Integer(i) for i in range(1,4)])+ text_1 = Text("ReplacementTransform", color=RED)+ r_transform.add(text_1)++ transform = VGroup(*[Integer(i) for i in range(4,7)])+ text_2 = Text("Transform", color=BLUE)+ transform.add(text_2)++ ints = VGroup(r_transform, transform)+ texts = VGroup(text_1, text_2).scale(0.75)+ r_transform.arrange(direction=UP, buff=1)+ transform.arrange(direction=UP, buff=1)++ ints.arrange(buff=2)+ self.add(ints, texts)++ # The mobs replace each other and none are left behind+ self.play(ReplacementTransform(r_transform[0], r_transform[1]))+ self.play(ReplacementTransform(r_transform[1], r_transform[2]))++ # The mobs linger after the Transform()+ self.play(Transform(transform[0], transform[1]))+ self.play(Transform(transform[1], transform[2]))+ self.wait()++ """+def __init__(self, mobject: Mobject, target_mobject: Mobject, **kwargs) -> None:super().__init__(mobject, target_mobject, replace_mobject_with_target_in_scene=True, **kwargs