← 返回首页

manim

为了给公式上色, 可以用 index_labels 来给公式上标签 <co … 继续阅读 →

为了给公式上色, 可以用 index_labels 来给公式上标签

<code class="language-python">self.add(index_labels(expectation[0]))</code>

对于 latex 公式的上色, 语法有点小奇怪. 比如 index_labels 显示出来只有0到41个标签, 但是分段显示的时候引用标签是[start_label, end_label+1], 代码最后一块就是 [40:42], 尽管标签的最大值为 41
<code class="language-python">self.play(Write(expectation[0][0:26]))
self.wait(1)
self.play(Write(expectation[0][26:40]))
self.wait(1)
self.play(Write(expectation[0][40:42]))
self.wait(1)</code>

上面的代码来自 distribution2.

当想让某个效果动起来, 比如 next_t0, shift, 可以用 animate

<code class="language-python">self.play(expr[2].animate.shift(UP*1.62))</code>

显示上色过程
<code class="language-python">self.play(ApplyMethod(new_expr.set_color, RED))</code>

常用这样的title
<code class="language-python">        title = MathTex(r"P_n\ \text{的计算}",
                        font_size=55,
                        tex_template=TexTemplateLibrary.ctex
                        ).to_edge(UP).set_color(YELLOW)</code>