manim中更改背景颜色后的对象颜色

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

Objects' color after changing background color in manim

问题

我尝试更改manim视频中场景的背景颜色为self.camera.background-color= WHITE,背景颜色变了,但所有文本仍然是白色。

有其他方法可以反转场景中的所有颜色吗,或者我们必须通过.set_color(BLACK)来定义每个对象的颜色?🤔 谢谢回复...还是新手😅

英文:

I'm trying to change the background of my Scene in manim video with a self.camera.background-color= WHITE, the background changed well but all texts are still white.

Is there any other methods to invert all colors in the scene or we have to define each object's color by a .set_color(BLACK) ??🤔 Thanks for responding...still newbie😅

答案1

得分: 1

from manim import *

config.background_color = "#a0a0a0"
Tex.set_default(color=BLACK)
MathTex.set_default(color=TEAL)
Text.set_default(color=PURE_GREEN)
Square.set_default(color=PURE_BLUE)
Circle.set_default(color=PURE_RED)

class test(Scene):
    def construct(self):
        sq = Square().to_corner(UR)
        circ = Circle().to_corner(UL)
        text = Text("Hello World").to_edge(LEFT)
        tex = Tex(r"Hello \LaTeX").shift(UP)
        mathtex = MathTex(r"a^2+b^2=c^2").shift(DOWN)
        self.add(sq, circ, text, tex, mathtex)

manim中更改背景颜色后的对象颜色

Manim Discord服务器上,有一些更高级的解决方案,可以定义自己的颜色方案。


<details>
<summary>英文:</summary>

You can set the default colors for all different types of objects in Manim.

```python
from manim import *

config.background_color = &quot;#a0a0a0&quot;
Tex.set_default(color=BLACK)
MathTex.set_default(color=TEAL)
Text.set_default(color=PURE_GREEN)
Square.set_default(color=PURE_BLUE)
Circle.set_default(color=PURE_RED)

class test(Scene):
    def construct(self):
        sq = Square().to_corner(UR)
        circ = Circle().to_corner(UL)
        text = Text(&quot;Hello World&quot;).to_edge(LEFT)
        tex = Tex(r&quot;Hello \LaTeX&quot;).shift(UP)
        mathtex = MathTex(r&quot;a^2+b^2=c^2&quot;).shift(DOWN)
        self.add(sq,circ,text,tex,mathtex)

manim中更改背景颜色后的对象颜色

On the Manim Discord server there are some more advanced solution for defining your own color schemes...

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

发表评论

匿名网友

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

确定