Manim文本不会闪烁。我得到的错误是“’c^’不是一个被识别的颜色”。

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

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()

Manim文本不会闪烁。我得到的错误是“’c^’不是一个被识别的颜色”。

英文:

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()

Manim文本不会闪烁。我得到的错误是“’c^’不是一个被识别的颜色”。

huangapple
  • 本文由 发表于 2023年7月27日 17:16:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76778232.html
匿名

发表评论

匿名网友

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

确定