- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最初的问题发布在 Reddit (https://www.reddit.com/r/manim/comments/lw3xs7/is_it_possible_to_run_manim_programmatically_and/) 上。我冒昧地在这里问。
假设我想编写一个简单的 GUI 应用程序,用户可以在其中输入 LaTeX 代码,单击“动画”按钮,然后 manim 在后台渲染 mp4,最后将动画呈现给用户。
是否可以使用 manim 作为模块来实现这一点?例如,通过将用户输入插入先前准备好的 manim 场景中,然后调用类似 my_scene.run(output=tempfile.mp4)
的内容。 ?或者我是否必须接受用户输入,将其写入新的 scene.py 文件并运行 os.subprocess("manim", "scene.py", "MyScene", "-p")
?
最佳答案
其实很简单。只需使用 .render(self)
要渲染的场景对象的方法。
from manim import *
# To open the movie after render.
from manim.utils.file_ops import open_file as open_media_file
class DemoScene(Scene):
def construct(self, alg):
image1 = ImageMobject(np.uint8([[63, 0, 0, 0],
[0, 127, 0, 0],
[0, 0, 191, 0],
[0, 0, 0, 255]
]))
image1.height = 7
self.add(image1)
self.wait(1)
if __name__ == '__main__':
scene = DemoScene()
scene.render() # That's it!
# Here is the extra step if you want to also open
# the movie file in the default video player
# (there is a little different syntax to open an image)
open_media_file(scene.renderer.file_writer.movie_file_path)
关于python - 是否可以以编程方式(而不是从命令行)运行 manim?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66642657/
我发现当文本超过 20 行时,此动画需要花费大量时间来渲染。我可以做些什么来加快速度吗? import itertools as it class FormulaExample(Scene): d
请您向我解释一下什么是 VGroup 以及它有什么用处?我试图寻找它,但显然无济于事,没有太多的文档。提前致谢。 最佳答案 基本上是一组VMobjects .所以说你有一些方程由多个单独的 Texmo
你能画对角线/箭头/任何看起来像你在manim数学方程中抵消的东西吗? 最佳答案 最接近的定义是 Cross ,但这并不完全是您要找的,我喜欢用这个: class Cancel(VGroup):
希望你们一切都好! 我想知道如何在 manim 中缩小文本。 我知道你可以做 text.scale(0.8),但我想知道使用后如何做。 例如, text.scale(0.8) self.play(Wr
希望你们一切都好! 我想知道如何在 manim 中缩小文本。 我知道你可以做 text.scale(0.8),但我想知道使用后如何做。 例如, text.scale(0.8) self.play(Wr
ORIGIN 中有一个正方形位置,我想将它移动到 UP*3 并使用以下代码片段同时缩放到 0.5: sq = Square() self.add(sq) self.play(ApplyMethod(s
我在 Manim Community v0.16.0.post0 中有以下文本: dioscuri = Text("DIOSCURI", weight=BOLD, font="Arial", colo
有什么办法可以增加动画中特定线条的宽度? 我试图改变DEFAULT_STROKE_WIDTH在 constants.py并设置 stroke_width在 CONFIG等于某个数字,但它不起作用。 这
txt11 = TexMobject(r"-7", color=BLACK) txt12 = TexMobject(r"\frac{1}{7}", color=BLACK).next_to(txt11
txt11 = TexMobject(r"-7", color=BLACK) txt12 = TexMobject(r"\frac{1}{7}", color=BLACK).next_to(txt11
我想用不同颜色绘制 MathTex 元素的变量,但 Manim 似乎对复杂的 Latex 表达式有问题。 这是我的场景。 from manim import * config.frame_width
this is the thing I wanted to make 我是 manim 的新手,我正在尝试将文本放在一个矩形内,如图中所示我怎样才能做到这一点 ?? :( 最佳答案 您可以使用 VGr
我主要尝试运行两个动画(引用以下代码): class RelTrain(Scene): def construct(self): train = Rectangle(heigh
无论如何,我正在尝试(这实际上是我的第一个 manim 程序)。 from manim import * import copy import numpy as np import random co
我开始学习 manim,希望你能帮助我理解这段代码是如何工作的 class Line_1(Scene): def construct(self): path = Line(LE
我是马尼姆新手。 与下面的示例一样, class scene_example(Scene): def construct(self): txt1 = Text("Text1")
我是马尼姆新手。 与下面的示例一样, class scene_example(Scene): def construct(self): txt1 = Text("Text1")
最初的问题发布在 Reddit (https://www.reddit.com/r/manim/comments/lw3xs7/is_it_possible_to_run_manim_programm
有没有办法使用 manim 显示 latex 表并为其设置动画? 例如 \begin{table}[] \centering \begin{tabular}{lllll} & & \multico
如果我有 3 行 manim 文本, l = TextMobject("Line 1") l2 = TextMobject("Line 2") l3 = TextMobject("Line 3")
我是一名优秀的程序员,十分优秀!