How to use the manimlib.animation.transform.Transform function in manimlib

To help you get started, we’ve selected a few manimlib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Solara570 / demo-solara / calissons.py View on Github external
def proof_part_2(self):
        self.play(
            DrawBorderThenFill(self.rhombi, submobject_mode = "all_at_once"),
            run_time = 2
        )
        self.wait()
        self.wait(12)
        self.play(Write(self.time_texts), run_time = 3)
        self.wait()
        source_texts = VGroup(*[texts[1] for texts in self.time_texts])
        target_texts = VGroup(*self.conclusions[0][::2])
        equal_signs = VGroup(self.conclusions[0][1::2])
        qed = self.conclusions[1]
        self.play(
            Transform(source_texts.copy(), target_texts),
            Write(equal_signs),
            run_time = 2
        )
        self.wait()
        self.play(FadeIn(qed))
        self.wait(2)
github 3b1b / manim / manimlib / scene / reconfigurable_scene.py View on Github external
def transition_between_states(self, start_state, target_state, **kwargs):
        self.play(Transform(start_state, target_state, **kwargs))
        self.wait()
github 3b1b / manim / manimlib / for_3b1b_videos / pi_creature_scene.py View on Github external
def get_student_changes(self, *modes, **kwargs):
        pairs = list(zip(self.get_students(), modes))
        pairs = [(s, m) for s, m in pairs if m is not None]
        start = VGroup(*[s for s, m in pairs])
        target = VGroup(*[s.copy().change_mode(m) for s, m in pairs])
        if "look_at_arg" in kwargs:
            for pi in target:
                pi.look_at(kwargs["look_at_arg"])
        anims = [
            Transform(s, t)
            for s, t in zip(start, target)
        ]
        return LaggedStart(
            *anims,
            lag_ratio=kwargs.get("lag_ratio", 0.5),
            run_time=1,
        )
github 3b1b / manim / manimlib / animation / transform.py View on Github external
super().__init__(self.group, **kwargs)

    def create_target(self):
        target = self.group.copy()
        cycled_targets = [target[-1], *target[:-1]]
        for m1, m2 in zip(cycled_targets, self.group):
            m1.move_to(m2)
        return target


class Swap(CyclicReplace):
    pass  # Renaming, more understandable for two entries


# TODO, this may be depricated...worth reimplementing?
class TransformAnimations(Transform):
    CONFIG = {
        "rate_func": squish_rate_func(smooth)
    }

    def __init__(self, start_anim, end_anim, **kwargs):
        digest_config(self, kwargs, locals())
        if "run_time" in kwargs:
            self.run_time = kwargs.pop("run_time")
        else:
            self.run_time = max(start_anim.run_time, end_anim.run_time)
        for anim in start_anim, end_anim:
            anim.set_run_time(self.run_time)

        if start_anim.starting_mobject.get_num_points() != end_anim.starting_mobject.get_num_points():
            start_anim.starting_mobject.align_data(end_anim.starting_mobject)
            for anim in start_anim, end_anim:
github 3b1b / manim / manimlib / scene / vector_space_scene.py View on Github external
def get_piece_movement(self, pieces):
        start = VGroup(*pieces)
        target = VGroup(*[mob.target for mob in pieces])
        if self.leave_ghost_vectors:
            self.add(start.copy().fade(0.7))
        return Transform(start, target, lag_ratio=0)
github Solara570 / demo-solara / calissons.py View on Github external
CONFIG = {
        "submobject_mode" : "lagged_start",
        "lag_factor" : 3,
        "run_time" : 3,
    }
    def __init__(self, ct_mob, **kwargs):
        digest_config(self, kwargs, locals())
        source_tiles = mobs_shuffle(ct_mob.get_all_tiles())
        target_tiles = source_tiles.copy()
        for tile in source_tiles:
            tile.scale_in_place(0)
            tile.set_stroke(width = 0)
        Transform.__init__(self, source_tiles, target_tiles, **kwargs)


class TilesShrink(Transform):
    CONFIG = {
        "submobject_mode" : "lagged_start",
        "lag_factor" : 3,
        "run_time" : 3,
    }
    def __init__(self, ct_mob, **kwargs):
        digest_config(self, kwargs, locals())
        source_tiles = mobs_shuffle(ct_mob.get_all_tiles())
        target_tiles = source_tiles.copy()
        for tile in target_tiles:
            tile.scale_in_place(0)
            tile.set_stroke(width = 0)
        Transform.__init__(self, source_tiles, target_tiles, **kwargs)

#####
## Main scenes
github 3b1b / manim / manimlib / scene / graph_scene.py View on Github external
new_right_v_line = self.get_vertical_line_to_graph(
                t_max, graph
            )
            new_right_v_line.set_color(right_v_line.get_color())
            right_T_label.move_to(new_right_v_line.get_bottom(), UP)

            # Fade close to 0
            if fade_close_to_origin:
                if len(left_T_label) > 0:
                    left_T_label[0].set_fill(opacity=min(1, np.abs(t_min)))
                if len(right_T_label) > 0:
                    right_T_label[0].set_fill(opacity=min(1, np.abs(t_max)))

            Transform(area, new_area).update(1)
            Transform(left_v_line, new_left_v_line).update(1)
            Transform(right_v_line, new_right_v_line).update(1)
            return group