manforowicz / Manim-Videos

The code I used to animate mathematical videos.
77 stars 7 forks source link

Text flip after coin flip. #2

Open gaozp opened 1 month ago

gaozp commented 1 month ago
class Coin(VMobject):

    def __init__(self, type, radius=0.4, **kwargs):
        super().__init__(**kwargs)

        if type == 'W':
            self.add(
                Circle(color=WHITE, fill_color=BLUE_E,
                       fill_opacity=1, radius=radius, stroke_width=5*radius),
                Tex("W", font_size=135*radius)
            )
        else:
            self.add(
                Circle(color=WHITE, fill_color=RED_E,
                       fill_opacity=1, radius=radius, stroke_width=5*radius),
                Tex("L", font_size=135*radius)
            )

    @override_animation(Create)
    def _create_override(self):
        return AnimationGroup(
            FadeIn(self, scale=1.2, shift=DOWN * 0.2),
            self.animate.flip(),
        )

The code

self.animate.flip()

will cause the text flip, like this :

image

Since you use T and H , that doesn't make any difference after flip . but if you use another character . this problem will occur .

I tried add flip() func after that.

    @override_animation(Create)
    def _create_override(self):
        return AnimationGroup(
            FadeIn(self, scale=1.2, shift=DOWN * 0.2),
            self.animate.flip(),
            self.animate.flip(),
        )

but not working.

gaozp commented 1 month ago

BTW, thanks for your great work! 👍