반응형
eq = TexMobject("a^2", "+", "b^2", "=", "c^2")
eq.save_state()
self.add(eq)
self.play(
eq[0].become,TexMobject("3^2").move_to(eq[0]),
eq[2].become,TexMobject("4^2").move_to(eq[2]),
eq[4].become,TexMobject("5^2").move_to(eq[4]),
run_time=2,
)
self.wait()
eq.restore()
self.add()
self.play(
Transform(eq[0], TexMobject("3^2").move_to(eq[0])),
Transform(eq[2], TexMobject("4^2").move_to(eq[2])),
Transform(eq[4], TexMobject("5^2").move_to(eq[4])),
run_time=2,
)
self.wait()
eq.restore()
self.add()
self.play(
Succession(
Transform(eq[0], TexMobject("3^2").move_to(eq[0])),
Transform(eq[2], TexMobject("4^2").move_to(eq[2])),
Transform(eq[4], TexMobject("5^2").move_to(eq[4])),
),
run_time=2,
)
self.wait(3)
class TextEqTest(Scene):
def construct(self):
self.method_a()
# self.method_b()
def method_a(self):
eq1 = ['a', '=', 'b', '+', 'e']
eq2 = ['a', '=', 'c + d', '+', 'e'] # since b=c+d
t1 = VGroup(*[TexMobject(eq) for eq in eq1]).arrange(RIGHT, buff=0.2)
t2 = VGroup(*[TexMobject(eq) for eq in eq2]).arrange(RIGHT, buff=0.2)
t2.next_to(t1, DOWN)
t1[2].set_color(RED) #b
t2[2].set_color(RED) #c+d
self.play(Write(t1), run_time=2)
self.play(LaggedStart(
TransformFromCopy(t1[0], t2[0]),
TransformFromCopy(t1[1], t2[1]),
TransformFromCopy(t1[2], t2[2]),
TransformFromCopy(t1[3], t2[3]),
TransformFromCopy(t1[4], t2[4]),
lag_ratio=0.9,
run_time=5,
))
self.wait()
반응형
'Programming > Manim code' 카테고리의 다른 글
[015]Text: font size (0) | 2020.05.05 |
---|---|
[014]Text/TextMobject/TexMobject (0) | 2020.05.05 |
[012]TextMobject.set_color/set_color_by_map (0) | 2020.05.05 |
[011]Text/TextMobject (0) | 2020.05.05 |
[010]save_state/restore (0) | 2020.05.05 |