FadeTransform#

Qualified name: manim.animation.transform.FadeTransform

class FadeTransform(mobject=None, *args, use_override=True, **kwargs)[source]#

Bases: 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

Clean up the Scene after finishing the animation.

get_all_families_zipped

get_all_mobjects

Get all mobjects involved in the animation.

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.

clean_up_from_scene(scene)[source]#

Clean up the Scene after finishing the animation.

This includes to remove() the Animation’s Mobject if the animation is a remover.

Parameters

scene – The scene the animation should be cleaned up from.

get_all_mobjects()[source]#

Get all mobjects involved in the animation.

Ordering must match the ordering of arguments to interpolate_submobject

Returns

The sequence of mobjects.

Return type

Sequence[Mobject]

ghost_to(source, target)[source]#

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

If the provided target has no points, and thus a location of [0, 0, 0] the source will simply fade out where it currently is.