Problem with a replacement transformation #3747
-
Hi everyone ! i'm a beginner on manim. I'm having trouble entering my code. The aim is to train myself, so I'm trying to give a little "demonstration" of a formula using animations. However, at the "ReplacementTransform(x,f)" step, the text x does the transformation animation but remains present, as if it were duplicated. I've managed to find a few discussions from people who've encountered this difficulty with an object but not with text, so I can't see what I'm missing in this step. Why does the text stay in place? Enclosed is my code. Thank you in advance. from manim import *
class demo1(Scene):
def construct(self):
t = Text("Sackur Tetrode relation")
self.play(Write(t),run_time=2)
self.wait(1)
z = Text("not a complete demo. Just a way to find the relation",font_size=28,color=RED)
self.play(ReplacementTransform(t, z))
self.wait(3)
self.play(Unwrite(z),run_time=1)
#s = MathTex("S = NkT^2 \left( \frac{\partial q}{\partial T} \right)_{V}")
s = MathTex(r"S = NkT^2 \left( \frac{\partial q}{\partial T} \right)_{V}")
self.play(Write(s),run_time=2)
self.wait(2)
self.play(s.animate.to_edge(UP))
q = MathTex(r"q = q_{trans} \frac{e}{N}")
n = MathTex(r"q_{trans} = \frac{V}{\Lambda^{3}}")
l = MathTex (r"q = \frac{Ve}{\Lambda^{3}N}")
x = MathTex(r"ln(q) = ln(Ve)-ln({\Lambda^3)-ln(N)}")
f = MathTex (r"ln(q) = ln(Ve)- 3ln({\Lambda)-ln(N)}")
a = MathTex(r"\Lambda = \frac{h}{\sqrt{2\pi mkT}}")
self.play(Write(q),run_time=2)
self.wait(2)
self.play(q.animate.to_edge(LEFT))
self.play(Write(n),run_time=2)
self.wait(2)
self.play(ReplacementTransform(q,l),ReplacementTransform(n,l))
self.wait(1)
self.play(ReplacementTransform(l,x))
self.wait(2)
self.play(ReplacementTransform(x,f))
self.wait(1)
self.play(f.animate.move_to([0,1.5,0]))
#self.play(Write(a),run_time=2) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
When you play the two animations self.play(ReplacementTransform(q,l),ReplacementTransform(n,l)) something odd happens that I'm not entirely sure I can fully explain. My best guess without investigating further is that the formula you store in self.play(ReplacementTransform(VGroup(q, n), l)) |
Beta Was this translation helpful? Give feedback.
When you play the two animations
something odd happens that I'm not entirely sure I can fully explain. My best guess without investigating further is that the formula you store in
l
somehow gets added to the scene twice. To avoid this sort of issue, you can group the two source mobjects together first and then transform the group, like this: