两个Manim动画不同时显示

huangapple go评论51阅读模式
英文:

Two manim animations not displaying at the same time

问题

class IntroToEquation(Scene):
def construct(self):
equation = MathTex(
"2^x=3",
substrings_to_isolate="x",
font_size=144
)
equation.set_color_by_tex("x", YELLOW)

    self.play(FadeIn(equation))
    self.wait(2)
    self.play(equation.animate.to_edge(UP, buff=0.5), equation.animate.scale(0.75))
    self.wait(1)
英文:

I have a sample of code that goes like this:

class IntroToEquation(Scene):
def construct(self):
    equation = MathTex(
        "2^x=3",
        substrings_to_isolate="x",
        font_size=144
    )
    equation.set_color_by_tex("x", YELLOW)

    self.play(FadeIn(equation))
    self.wait(2)
    self.play(equation.animate.to_edge(UP, buff=0.5), equation.animate.scale(0.75))
    self.wait(1)

and the third self.play() contains two things that should be going at the same time, but only the scaling is played in the final video. From everything that I've looked at this should be working. Any help is appreciated, and thank you for your time.

答案1

得分: 1

由于Manim中处理动画的方式,您不能同时在同一个对象上有两种不同的动画。但您可以通过叠加单独的变换来创建复合动画:

class IntroToEquation(Scene):
    def construct(self):
        equation = MathTex(
            "2^x=3",
            substrings_to_isolate="x",
            font_size=144
        )
        equation.set_color_by_tex("x", YELLOW)

        self.play(FadeIn(equation))
        self.wait(2)
        self.play(equation.animate.to_edge(UP, buff=0.5).scale(0.75))
        self.wait(1) 
英文:

Because of the way animations are handled in Manim, you cannot have two different animations on the same object at the same time. But you can make a composite animation by stacking the individual transformations:

class IntroToEquation(Scene):
    def construct(self):
        equation = MathTex(
            "2^x=3",
            substrings_to_isolate="x",
            font_size=144
        )
        equation.set_color_by_tex("x", YELLOW)

        self.play(FadeIn(equation))
        self.wait(2)
        self.play(equation.animate.to_edge(UP, buff=0.5).scale(0.75))
        self.wait(1) 

两个Manim动画不同时显示

Come over to Discord if you want to learn more tips and tricks

huangapple
  • 本文由 发表于 2023年6月14日 23:26:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76475200.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定