英文:
Manim Text does not bilink. The error i get is "'c^' is not a recognized color"
问题
class FlashAnimationEffect(Scene):
def construct(self):
tex = Text("E", "=", "m", "c^", "2").scale(2)
self.play(Write(tex))
self.wait()
self.play(Flash(tex[1], flash_radius=0.6), run_time=2)
self.wait()
错误提示显示c^
不是一个被识别的颜色。当我删除c^
后,下一个错误是相同的,只是与"2"
有关。谢谢你的时间和回答。
英文:
class FlashAnimationEffect(Scene):
def construct(self):
tex= Text("E","=","m","c^","2").scale(2)
self.play(Write(tex))
self.wait()
self.play(Flash(tex[1],flash_radius=0.6),run_time=2)
self.wait()
The Error says that 'c^' is not a recognized color. When I delete c^ the next error is the same but with "2". Thanks for your time and your answer
答案1
得分: 0
class FlashAnimationEffect(Scene):
def construct(self):
tex = Tex("E", "=", "m", "c^", "2").scale(2)
self.play(Write(tex))
self.wait()
self.play(Flash(tex[1], flash_radius=0.6), run_time=2)
self.wait()
答案是将Text更改为Tex,现在它可以工作了。
英文:
class FlashAnimationEffect(Scene):
def construct(self):
tex= Tex("E","=","m","c^","2").scale(2)
self.play(Write(tex))
self.wait()
self.play(Flash(tex[1],flash_radius=0.6),run_time=2)
self.wait()
The answer is to change Text to Tex and now it works
答案2
得分: 0
你正在使用Text()
来创建文本,但是这个对象不接受多个字符串作为参数(只有第一个字符串被视为要渲染的文本,其他字符串被视为其他参数,特别是第四个字符串被期望是颜色,因此出现了错误)。
你可能想使用Tex()
或MathTex()
。下面的代码可以正常工作:
class Test(Scene):
def construct(self):
tex = MathTex("E", "=", "m", "c^", "2").scale(2)
self.play(Write(tex))
self.wait()
self.play(Flash(tex[1], flash_radius=0.6), run_time=2)
self.wait()
英文:
You are using Text()
to create your text, but this object does not accept several strings as arguments (only the first one is considererd the text to render, and the others are considered other arguments, in particular the fourth one is expected to be the color, hence your error).
You probably wanted to use Tex()
or MathTex()
. This one works:
class Test(Scene):
def construct(self):
tex= MathTex("E","=","m","c^","2").scale(2)
self.play(Write(tex))
self.wait()
self.play(Flash(tex[1], flash_radius=0.6),run_time=2)
self.wait()
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论