Manim配置。
1. ManimConfig
ManimConfig用字典存储了所有配置选项,可以修改配置和获取参数的值,举例:
from manim import *
# 获取选项值
color = config["background_color"]
# 修改默认值
config.background_color = WHITE # OR
config['background_color'] = WHITE
2. 所有配置选项的默认值
使用Python内置方法vars得到config
类所有键值的属性。
for k, v in sorted(vars(config)['_d'].items()):
print('{}: \t\t\t\t{}'.format(k, v))
再手动稍微归类下,得到如下如果:
PS D:\workspace\manim> manim test.py Test
Manim Community v0.14.0
assets_dir: ./
background_color: black
background_opacity: 1.0
custom_folders: False
disable_caching: False
disable_caching_warning: False
max_files_cached: 100
dry_run: False
enable_gui: False
enable_wireframe: False
ffmpeg_loglevel: ERROR
flush_cache: False
force_window: False
format: None
frame_height: 8.0
frame_rate: 60.0
frame_width: 14.222222222222221
frame_x_radius: None
frame_y_radius: None
pixel_height: 1080
pixel_width: 1920
from_animation_number: 0
fullscreen: False
gui_location: (0, 0)
media_dir: ./media
media_width: 60%
movie_file_extension: .mp4
notify_outdated_version: True
output_file: None
images_dir: {media_dir}/images/{module_name}
input_file: D:\workspace\manim\test.py
log_dir: {media_dir}/logs
log_to_file: False
partial_movie_dir: {video_dir}/partial_movie_files/{scene_name}
sections_dir: {video_dir}/sections
tex_dir: {media_dir}/Tex
tex_template_file: None
text_dir: {media_dir}/texts
video_dir: {media_dir}/videos/{module_name}/{quality}
plugins: []
preview: False
progress_bar: display
quality: None
renderer: cairo
save_as_gif: False
save_last_frame: False
save_pngs: False
save_sections: False
scene_names: ('Test',)
show_in_file_browser: False
upto_animation_number: inf
use_opengl_renderer: False
use_projection_fill_shaders: False
use_projection_stroke_shaders: False
use_webgl_renderer: False
verbosity: INFO
webgl_renderer_path:
window_monitor: 0
window_position: UR
window_size: default
write_all: False
write_to_movie: True
zero_pad: 4
3. 一些使用经验
(1)产生视频不能同时将最后一帧保存为图像
出现错误Invalid data found when processing input
:
> manim daysofthisyear.py DaysOfThisYear
Manim Community v0.14.0
[01/25/22 16:18:40] INFO Combining to Movie file. scene_file_writer.py:608
D:\workspace\manim\media\partial_movie_files\partial_movie_file_list.txt: Invalid data found when processing input
原因是设置了config['save_last_frame'] = True
。详情见这里讨论:Using config.save_last_frame = True
causes manim 0.6.0 to fail at generating video output. · Issue #1487。
(2)要不要用缓存
Manim默认是使用动画缓存来加快产生视频,但有时候得到的视频并没有更新。可以配置选项,将缓存关掉。
config['disable_caching'] = True