3b1b / 3b1b/manim

Tex not appearing after coloring

未關閉
#1,298 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
93.9k
分支
7.7k
平均合併
2 天 13 小時
30 天內合併 PR
4

描述

Hi! I'm having some trouble with `TexMobject` when using `tex_to_color_map`.

```python
class Test(Scene):
def construct(self):
tex = TexMobject(
"\\frac{\\partial E}{\\partial y_1}",
"=& \\frac{\\partial}{\\partial y_1} \\frac{1}{n} \\Big[ (y^*_1 - y_1)^2 + (y^*_2 - y_2)^2 + \\cdots + (y^*_n - y_n)^2 \\Big] \\\\",
"=& \\frac{\\partial}{\\partial y_1} \\frac{1}{n} (y^*_1 - y_1)^2 \\\\",
"=& \\frac{2}{n} (y_1 - y^*_1)",
tex_to_color_map={
"y^*_1": BLUE,
"y^*_2": BLUE,
"y^*_n": BLUE,
"y_1": RED,
"y_2": RED,
"y_n": RED
}
)
self.play(Write(tex)) # last part of the equation does not appear
self.wait()
```

If I don't use `tex_to_color_map` it works as one would expect, otherwise the last part of the equation is not displayed.
Also, if I use `self.add(tex)` instead of `self.play(Write(tex))` then it works.

Another issue is that when I set `tex_to_color_map` then the indexing behaves strangely.
Doing `self.play(Write(tex[0]))` without `tex_to_color_map` correctly displays the tex in the first string, but when it is set it will only display a subpart of the first string.

Maybe I am missing something here...

Amazing library by the way! Thank you!

貢獻指南

這個儲存庫沒有索引到貢獻指南

研究方向

查看 manim/mobject/svg/tex_mobject.py 中的 TexMobject 類別,重點關注 tex_to_color_map 的處理方式,以及它如何影響子字串的索引和渲染。這個 bug 在使用 Write 動畫與 direct add 時會顯現。先用提供的測試場景重現問題,然後追蹤色彩映射邏輯,查看為何最後一部分消失且索引中斷。

由索引模型根據 Issue 內容生成。

評估

領域
computer-graphics
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
描述清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。