manim.animation.transform.FadeTransform

class FadeTransform(mobject, target_mobject, stretch=True, dim_to_match=1, **kwargs)[source]

Bases: manim.animation.transform.Transform

Fades one mobject into another.

Parameters
  • mobject – The starting Mobject.

  • target_mobject – The target Mobject.

  • stretch – Controls whether the target Mobject is stretched during the animation. Default: True.

  • dim_to_match – If the target mobject is not stretched automatically, this allows to adjust the initial scale of the target Mobject while it is shifted in. Setting this to 0, 1, and 2, respectively, matches the length of the target with the length of the starting Mobject in x, y, and z direction, respectively.

  • kwargs – Further keyword arguments are passed to the parent class.

Examples

Example: DifferentFadeTransforms

from manim import *

class DifferentFadeTransforms(Scene):
    def construct(self):
        starts = [Rectangle(width=4, height=1) for _ in range(3)]
        VGroup(*starts).arrange(DOWN, buff=1).shift(3*LEFT)
        targets = [Circle(fill_opacity=1).scale(0.25) for _ in range(3)]
        VGroup(*targets).arrange(DOWN, buff=1).shift(3*RIGHT)

        self.play(*[FadeIn(s) for s in starts])
        self.play(
            FadeTransform(starts[0], targets[0], stretch=True),
            FadeTransform(starts[1], targets[1], stretch=False, dim_to_match=0),
            FadeTransform(starts[2], targets[2], stretch=False, dim_to_match=1)
        )

        self.play(*[FadeOut(mobj) for mobj in self.mobjects])

Methods

begin

Initial setup for the animation.

clean_up_from_scene

get_all_families_zipped

get_all_mobjects

Ordering must match the ordering of arguments to interpolate_submobject

ghost_to

Replaces the source by the target and sets the opacity to 0.

Attributes

path_arc

path_func

begin()[source]

Initial setup for the animation.

The mobject to which this animation is bound is a group consisting of both the starting and the ending mobject. At the start, the ending mobject replaces the starting mobject (and is completely faded). In the end, it is set to be the other way around.

get_all_mobjects()[source]

Ordering must match the ordering of arguments to interpolate_submobject

ghost_to(source, target)[source]

Replaces the source by the target and sets the opacity to 0.