How to use the manimlib.animation.transform.ReplacementTransform 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 / short / ford_circles.py View on Github external
def play_farey_sum_animation(self, p1, q1, p2, q2):
        c1, c2, c3, l1, l2, l3 = self.get_farey_sum_key_mobjects(p1, q1, p2, q2)
        l3.set_color(PINK)
        self.wait()
        self.play(
            ShowCreation(c1), ApplyMethod(l1.set_color, YELLOW),
            ShowCreation(c2), ApplyMethod(l2.set_color, YELLOW),
        )
        self.play(
            ReplacementTransform(l1.numer.deepcopy(), l3.numer),
            ReplacementTransform(l1.line.deepcopy(), l3.line),
            ReplacementTransform(l1.denom.deepcopy(), l3.denom),
            ReplacementTransform(l2.numer.deepcopy(), l3.numer),
            ReplacementTransform(l2.line.deepcopy(), l3.line),
            ReplacementTransform(l2.denom.deepcopy(), l3.denom),
            ReplacementTransform(c1.deepcopy(), c3),
            ReplacementTransform(c2.deepcopy(), c3),
        )
        self.wait()
        self.play(FadeOut(VGroup(c1, c2, c3, l1, l2, l3)))
github Solara570 / demo-solara / short / ford_circles.py View on Github external
def play_farey_sum_animation(self, p1, q1, p2, q2):
        c1, c2, c3, l1, l2, l3 = self.get_farey_sum_key_mobjects(p1, q1, p2, q2)
        l3.set_color(PINK)
        self.wait()
        self.play(
            ShowCreation(c1), ApplyMethod(l1.set_color, YELLOW),
            ShowCreation(c2), ApplyMethod(l2.set_color, YELLOW),
        )
        self.play(
            ReplacementTransform(l1.numer.deepcopy(), l3.numer),
            ReplacementTransform(l1.line.deepcopy(), l3.line),
            ReplacementTransform(l1.denom.deepcopy(), l3.denom),
            ReplacementTransform(l2.numer.deepcopy(), l3.numer),
            ReplacementTransform(l2.line.deepcopy(), l3.line),
            ReplacementTransform(l2.denom.deepcopy(), l3.denom),
            ReplacementTransform(c1.deepcopy(), c3),
            ReplacementTransform(c2.deepcopy(), c3),
        )
        self.wait()
        self.play(FadeOut(VGroup(c1, c2, c3, l1, l2, l3)))
github Solara570 / demo-solara / short / kkd / kkd.py View on Github external
arranged_terms_list.append(cdots_copy)
                arranged_terms = VGroup(*arranged_terms_list)
                arranged_terms.arrange_submobjects(RIGHT, buff = 0.2)
                arranged_terms.next_to(self.sum_tex, UP, aligned_edge = RIGHT, buff = 0.5)
                # Move highlighted terms into position
                anims_list = []
                for i in range(4):
                    anims_list.append(
                        ReplacementTransform(
                            self.get_highlighted_terms(n)[i].deepcopy(),
                            arranged_terms[2*i],
                            lag_ratio = 0, run_time = 2
                        )
                    )
                    anims_list.append(
                        ReplacementTransform(
                            self.get_times_symbols()[i].deepcopy(),
                            arranged_terms[2*i+1],
                            lag_ratio = 0, run_time = 2
                        )
                    )
                anims_list.append(
                    ReplacementTransform(
                        self.get_cdots_symbol().deepcopy(),
                        arranged_terms[-1],
                        lag_ratio = 0, run_time = 2
                    )
                )
                self.play(AnimationGroup(*anims_list))
                self.wait()
                if n == 1:
                    self.play(
github 3b1b / manim / manimlib / for_3b1b_videos / pi_creature_scene.py View on Github external
return hasattr(pi, "bubble") and \
                pi.bubble is not None and \
                pi.bubble in on_screen_mobjects

        pi_creatures_with_bubbles = list(filter(has_bubble, self.get_pi_creatures()))
        if pi_creature in pi_creatures_with_bubbles:
            pi_creatures_with_bubbles.remove(pi_creature)
            old_bubble = pi_creature.bubble
            bubble = pi_creature.get_bubble(
                *content,
                bubble_class=bubble_class,
                **bubble_kwargs
            )
            anims += [
                ReplacementTransform(old_bubble, bubble),
                ReplacementTransform(old_bubble.content, bubble.content),
                pi_creature.change_mode, target_mode
            ]
        else:
            anims.append(PiCreatureBubbleIntroduction(
                pi_creature,
                *content,
                bubble_class=bubble_class,
                bubble_kwargs=bubble_kwargs,
                target_mode=target_mode,
                **kwargs
            ))
        anims += [
            RemovePiCreatureBubble(pi, **bubble_removal_kwargs)
            for pi in pi_creatures_with_bubbles
        ]
        anims += added_anims
github 3b1b / manim / manimlib / for_3b1b_videos / pi_creature_scene.py View on Github external
def has_bubble(pi):
            return hasattr(pi, "bubble") and \
                pi.bubble is not None and \
                pi.bubble in on_screen_mobjects

        pi_creatures_with_bubbles = list(filter(has_bubble, self.get_pi_creatures()))
        if pi_creature in pi_creatures_with_bubbles:
            pi_creatures_with_bubbles.remove(pi_creature)
            old_bubble = pi_creature.bubble
            bubble = pi_creature.get_bubble(
                *content,
                bubble_class=bubble_class,
                **bubble_kwargs
            )
            anims += [
                ReplacementTransform(old_bubble, bubble),
                ReplacementTransform(old_bubble.content, bubble.content),
                pi_creature.change_mode, target_mode
            ]
        else:
            anims.append(PiCreatureBubbleIntroduction(
                pi_creature,
                *content,
                bubble_class=bubble_class,
                bubble_kwargs=bubble_kwargs,
                target_mode=target_mode,
                **kwargs
            ))
        anims += [
            RemovePiCreatureBubble(pi, **bubble_removal_kwargs)
            for pi in pi_creatures_with_bubbles
        ]