假设有两个 self.play 语句,第一个从 1 秒开始,我希望秒数从一开始正好 3 秒开始。
目前我使用 self.wait 来控制步骤:
self.wait(1)
self.play...... # first animation
self.wait(2) # because 1 + 2 = 3
self.play...... # second animation
Run Code Online (Sandbox Code Playgroud)
但是,由于第一个动画需要一些时间(例如 1.5 秒)才能完成,因此实际上第二个动画将在 1 + 1.5 + 2 = 4.5 秒时开始。
如何让第二个 self.play 从开始后 3 秒开始运行?提前致谢。
场景很简单,一行并旋转 PI/2,代码如下:
ln = Line(ORIGIN, RIGHT*2)
self.add(ln)
self.wait()
self.play(ApplyMethod(ln.rotate, PI/2, OUT))
Run Code Online (Sandbox Code Playgroud)
然而,在旋转过程中,看似同时缩放,我检查轴是[0 0 1],即z轴,我认为线的长度应该保持不变。
如何防止线路结垢?谢谢!
我不想使用 Manim 创建一个小动画。有一个矩形,将在其中绘制两条线(在矩形的左侧和底侧),并且新的矩形应从底部“生长”。使用GrowFromEdge(element, DOWN)矩形的宽度也会改变,但只有高度应该改变。我该怎么办?使用height=0然后ApplyMethod(element.set_height, HEIGHT)不显示任何内容。这是我的代码:
from manimlib.imports import *
from manimlib.constants import COLOR_MAP
import numpy as np
class Test(Scene):
def construct(self):
EXPLAIN_WIDTH = 5
EXPLAIN_HEIGHT = 2
explain_rect = Rectangle(
width=EXPLAIN_WIDTH,
height=EXPLAIN_HEIGHT,
origin=np.array(
[0,
0,
0]
)
).set_stroke(width=1)
explain_line_left = Line(
start=np.array(
[EXPLAIN_WIDTH / -2,
EXPLAIN_HEIGHT / -2,
0]
),
end=np.array(
[EXPLAIN_WIDTH / -2,
EXPLAIN_HEIGHT / 2,
0]
),
).set_color(COLOR_MAP["RED_A"])
explain_line_bottom = Line(
start=np.array(
[EXPLAIN_WIDTH / -2,
EXPLAIN_HEIGHT / -2,
0]
),
end=np.array(
[EXPLAIN_WIDTH …Run Code Online (Sandbox Code Playgroud) 马尼姆社区 v0.15.1
我是马尼姆的新手。我一直在尝试更改 Tex 和 Text 对象的字体颜色,而不必单独设置每个 Tex 或 Text 对象的颜色。
如何更改场景内或全局中所有 Tex 和 Text 对象的字体颜色?
以下是一些我相信我尝试过但一无所获的解决方案:
https://github.com/3b1b/manim/issues/1145
我认为这一切都与 Manim 的以下内容有关: https://docs.manim.community/en/stable/installation/troubleshooting.html ?highlight=config#config
这是我的代码示例:
from manim import *
class My_made_Up_Scene_Name(Scene):
def construct(self):
text_1 = Text("Text_1", font = "Arial", font_size = 50)
Run Code Online (Sandbox Code Playgroud)
我应该在哪里插入场景范围内的字体颜色变化?
编辑:请检查我在下面写的评论
我正在运行 macOS High Sierra 10.13.6,我认为我下载的 PIL 库版本(可能使用brew install py3cairo)与我的操作系统不兼容。电脑还预装了python2。我已经安装了 ffmpeg 并将其存储在文档中,在一些帮助下,我将其放置在路径中,因此当我在终端中输入时:
>>> echo $PATH
Run Code Online (Sandbox Code Playgroud)
输出是:
Users/imac/Documents/ffmpeg:/Library/Frameworks/Python.framework/Versions/3.9/bin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/anaconda3/condabin:/Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin
当我运行一个应该可以工作的简单程序时,我的终端输出(从 manim 教程复制粘贴):
Traceback (most recent call last):
...(omitted)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/Image.py", line 132, in <module>
from . import _imaging as core
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/_imaging.cpython-39-darwin.so,
2): Symbol not found: ____chkstk_darwin
Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/.dylibs/libtiff.5.dylib
(which was built for Mac OS X 11.0)
Expected in: /usr/lib/libSystem.B.dylib
in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/PIL/.dylibs/libtiff.5.dylib```
Run Code Online (Sandbox Code Playgroud) 我发现这些代码行周围不准确。
from manim import *
class CodeTrackingAnimation(Scene):
def construct(self):
code_str = '''#include<iostream>
using namespace std;
int main(){
int sum = 0;
for(int i=0;i<n;i++){
sum += i;
}
return 0;
}'''
code = self.build_code_block(code_str)
for i in range(len(code.code)-1):
self.highlight(i, i+1)
def build_code_block(self, code_str):
# build the code block
code = Code(code=code_str, language='C++', background="window")
self.add(code)
# build sliding windows (SurroundingRectangle)
self.sliding_wins = VGroup()
height = code.code[0].height
for line in code.code:
self.sliding_wins.add(SurroundingRectangle(line).set_fill(YELLOW).set_opacity(0))
self.add(self.sliding_wins)
return code
def highlight(self, prev_line, line):
self.play(self.sliding_wins[prev_line].animate.set_opacity(0.3))
self.play(ReplacementTransform(self.sliding_wins[prev_line], self.sliding_wins[line]))
self.play(self.sliding_wins[line].animate.set_opacity(0.3)) …Run Code Online (Sandbox Code Playgroud)