mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
add auto config guide
This commit is contained in:
parent
2394bdc2e6
commit
e3d09d161c
5 changed files with 112 additions and 120 deletions
|
@ -1,56 +0,0 @@
|
||||||
directories:
|
|
||||||
# Set this to true if you want the path to video files
|
|
||||||
# to match the directory structure of the path to the
|
|
||||||
# sourcecode generating that video
|
|
||||||
mirror_module_path: False
|
|
||||||
# Where should manim output video and image files?
|
|
||||||
output: ""
|
|
||||||
# If you want to use images, manim will look to these folders to find them
|
|
||||||
raster_images: ""
|
|
||||||
vector_images: ""
|
|
||||||
# If you want to use sounds, manim will look here to find it.
|
|
||||||
sounds: ""
|
|
||||||
# Manim often generates tex_files or other kinds of serialized data
|
|
||||||
# to keep from having to generate the same thing too many times. By
|
|
||||||
# default, these will be stored at tempfile.gettempdir(), e.g. this might
|
|
||||||
# return whatever is at to the TMPDIR environment variable. If you want to
|
|
||||||
# specify them elsewhere,
|
|
||||||
temporary_storage: ""
|
|
||||||
tex:
|
|
||||||
executable: "latex"
|
|
||||||
template_file: "tex_template.tex"
|
|
||||||
intermediate_filetype: "dvi"
|
|
||||||
text_to_replace: "[tex_expression]"
|
|
||||||
# For ctex, use the following configuration
|
|
||||||
# executable: "xelatex -no-pdf"
|
|
||||||
# template_file: "ctex_template.tex"
|
|
||||||
# intermediate_filetype: "xdv"
|
|
||||||
universal_import_line: "from manimlib import *"
|
|
||||||
style:
|
|
||||||
font: "Consolas"
|
|
||||||
background_color: "#333333"
|
|
||||||
# Set the position of preview window, you can use directions, e.g. UL/DR/OL/OO/...
|
|
||||||
# also, you can also specify the position(pixel) of the upper left corner of
|
|
||||||
# the window on the monitor, e.g. "960,540"
|
|
||||||
window_position: UR
|
|
||||||
# If break_into_partial_movies is set to True, then many small
|
|
||||||
# files will be written corresponding to each Scene.play and
|
|
||||||
# Scene.wait call, and these files will then be combined
|
|
||||||
# to form the full scene. Sometimes video-editing is made
|
|
||||||
# easier when working with the broken up scene, which
|
|
||||||
# effectively has cuts at all the places you might want.
|
|
||||||
break_into_partial_movies: False
|
|
||||||
camera_qualities:
|
|
||||||
low:
|
|
||||||
resolution: "854x480"
|
|
||||||
frame_rate: 15
|
|
||||||
medium:
|
|
||||||
resolution: "1280x720"
|
|
||||||
frame_rate: 30
|
|
||||||
high:
|
|
||||||
resolution: "1920x1080"
|
|
||||||
frame_rate: 30
|
|
||||||
ultra_high:
|
|
||||||
resolution: "3840x2160"
|
|
||||||
frame_rate: 60
|
|
||||||
default_quality: "high"
|
|
|
@ -1,10 +1,15 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import manimlib.config
|
import manimlib.config
|
||||||
import manimlib.extract_scene
|
import manimlib.extract_scene
|
||||||
|
import manimlib.utils.init_config
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = manimlib.config.parse_cli()
|
args = manimlib.config.parse_cli()
|
||||||
|
|
||||||
|
if args.config:
|
||||||
|
manimlib.utils.init_config.init_customization()
|
||||||
|
else:
|
||||||
config = manimlib.config.get_configuration(args)
|
config = manimlib.config.get_configuration(args)
|
||||||
scenes = manimlib.extract_scene.main(config)
|
scenes = manimlib.extract_scene.main(config)
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import yaml
|
||||||
from screeninfo import get_monitors
|
from screeninfo import get_monitors
|
||||||
|
|
||||||
from manimlib.utils.config_ops import merge_dicts_recursively
|
from manimlib.utils.config_ops import merge_dicts_recursively
|
||||||
|
from manimlib.utils.init_config import init_customization
|
||||||
|
|
||||||
|
|
||||||
def parse_cli():
|
def parse_cli():
|
||||||
|
@ -98,6 +99,11 @@ def parse_cli():
|
||||||
"--file_name",
|
"--file_name",
|
||||||
help="Name for the movie or image file",
|
help="Name for the movie or image file",
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--config",
|
||||||
|
action="store_true",
|
||||||
|
help="Guide for automatic configuration",
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-n", "--start_at_animation_number",
|
"-n", "--start_at_animation_number",
|
||||||
help="Start rendering not from the first animation, but"
|
help="Start rendering not from the first animation, but"
|
||||||
|
@ -152,9 +158,18 @@ def get_module(file_name):
|
||||||
|
|
||||||
def get_custom_defaults():
|
def get_custom_defaults():
|
||||||
filename = "custom_defaults.yml"
|
filename = "custom_defaults.yml"
|
||||||
manim_defaults_file = os.path.join(get_manim_dir(), "manimlib", "defaults.yml")
|
global_defaults_file = os.path.join(get_manim_dir(), "manimlib", "defaults.yml")
|
||||||
with open(manim_defaults_file, "r") as file:
|
|
||||||
|
if not (os.path.exists(global_defaults_file) or os.path.exists(filename)):
|
||||||
|
print("There is no configuration file detected. Initial configuration:\n")
|
||||||
|
init_customization()
|
||||||
|
|
||||||
|
if os.path.exists(global_defaults_file):
|
||||||
|
with open(global_defaults_file, "r") as file:
|
||||||
custom_defaults = yaml.safe_load(file)
|
custom_defaults = yaml.safe_load(file)
|
||||||
|
else:
|
||||||
|
with open(filename, "r") as file:
|
||||||
|
local_defaults = yaml.safe_load(file)
|
||||||
|
|
||||||
# See if there's a custom_defaults file in current directory,
|
# See if there's a custom_defaults file in current directory,
|
||||||
# and if so, it further updates the defaults based on it.
|
# and if so, it further updates the defaults based on it.
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
directories:
|
|
||||||
# Set this to true if you want the path to video files
|
|
||||||
# to match the directory structure of the path to the
|
|
||||||
# sourcecode generating that video
|
|
||||||
mirror_module_path: False
|
|
||||||
# Where should manim output video and image files?
|
|
||||||
output: ""
|
|
||||||
# If you want to use images, manim will look to these folders to find them
|
|
||||||
raster_images: ""
|
|
||||||
vector_images: ""
|
|
||||||
# If you want to use sounds, manim will look here to find it.
|
|
||||||
sounds: ""
|
|
||||||
# Manim often generates tex_files or other kinds of serialized data
|
|
||||||
# to keep from having to generate the same thing too many times. By
|
|
||||||
# default, these will be stored at tempfile.gettempdir(), e.g. this might
|
|
||||||
# return whatever is at to the TMPDIR environment variable. If you want to
|
|
||||||
# specify them elsewhere,
|
|
||||||
temporary_storage: ""
|
|
||||||
tex:
|
|
||||||
executable: "latex"
|
|
||||||
template_file: "tex_template.tex"
|
|
||||||
intermediate_filetype: "dvi"
|
|
||||||
text_to_replace: "[tex_expression]"
|
|
||||||
# # For ctex, use the following configuration
|
|
||||||
# executable: "xelatex -no-pdf"
|
|
||||||
# template_file: "ctex_template.tex"
|
|
||||||
# intermediate_filetype: "xdv"
|
|
||||||
universal_import_line: "from manimlib import *"
|
|
||||||
style:
|
|
||||||
font: "Consolas"
|
|
||||||
background_color: "#333333"
|
|
||||||
# Set the position of preview window, you can use directions, e.g. UL/DR/OL/OO/...
|
|
||||||
# also, you can also specify the position(pixel) of the upper left corner of
|
|
||||||
# the window on the monitor, e.g. "960,540"
|
|
||||||
window_position: UR
|
|
||||||
# If break_into_partial_movies is set to True, then many small
|
|
||||||
# files will be written corresponding to each Scene.play and
|
|
||||||
# Scene.wait call, and these files will then be combined
|
|
||||||
# to form the full scene. Sometimes video-editing is made
|
|
||||||
# easier when working with the broken up scene, which
|
|
||||||
# effectively has cuts at all the places you might want.
|
|
||||||
break_into_partial_movies: False
|
|
||||||
camera_qualities:
|
|
||||||
low:
|
|
||||||
resolution: "854x480"
|
|
||||||
frame_rate: 15
|
|
||||||
medium:
|
|
||||||
resolution: "1280x720"
|
|
||||||
frame_rate: 30
|
|
||||||
high:
|
|
||||||
resolution: "1920x1080"
|
|
||||||
frame_rate: 30
|
|
||||||
ultra_high:
|
|
||||||
resolution: "3840x2160"
|
|
||||||
frame_rate: 60
|
|
||||||
default_quality: "high"
|
|
84
manimlib/utils/init_config.py
Normal file
84
manimlib/utils/init_config.py
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
import yaml
|
||||||
|
import os
|
||||||
|
|
||||||
|
def init_customization():
|
||||||
|
configuration = {
|
||||||
|
"directories": {
|
||||||
|
"mirror_module_path": False,
|
||||||
|
"output": "",
|
||||||
|
"raster_images": "",
|
||||||
|
"vector_images": "",
|
||||||
|
"sounds": "",
|
||||||
|
"temporary_storage": "",
|
||||||
|
},
|
||||||
|
"tex": {
|
||||||
|
"executable": "",
|
||||||
|
"template_file": "",
|
||||||
|
"intermediate_filetype": "",
|
||||||
|
"text_to_replace": "[tex_expression]",
|
||||||
|
},
|
||||||
|
"universal_import_line": "from manimlib import *",
|
||||||
|
"style": {
|
||||||
|
"font": "Consolas",
|
||||||
|
"background_color": "",
|
||||||
|
},
|
||||||
|
"window_position": "UR",
|
||||||
|
"break_into_partial_movies": False,
|
||||||
|
"camera_qualities": {
|
||||||
|
"low": {
|
||||||
|
"resolution": "854x480",
|
||||||
|
"frame_rate": 15,
|
||||||
|
},
|
||||||
|
"medium": {
|
||||||
|
"resolution": "1280x720",
|
||||||
|
"frame_rate": 30,
|
||||||
|
},
|
||||||
|
"high": {
|
||||||
|
"resolution": "1920x1080",
|
||||||
|
"frame_rate": 60,
|
||||||
|
},
|
||||||
|
"ultra_high": {
|
||||||
|
"resolution": "3840x2160",
|
||||||
|
"frame_rate": 60,
|
||||||
|
},
|
||||||
|
"default_quality": "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
scope = input(" Please select the scope of the configuration [global/local]: ")
|
||||||
|
if scope == "global":
|
||||||
|
from manimlib.config import get_manim_dir
|
||||||
|
file_name = os.path.join(get_manim_dir(), "manimlib", "defaults.yml")
|
||||||
|
else:
|
||||||
|
file_name = os.path.join(os.getcwd(), "custom_defaults.yml")
|
||||||
|
|
||||||
|
print("\n directories:")
|
||||||
|
configuration["directories"]["output"] = input(" [1/8] Where should manim output video and image files place: ")
|
||||||
|
configuration["directories"]["raster_images"] = input(" [2/8] Which folder should manim find raster images (.jpg .png .gif) in (optional): ")
|
||||||
|
configuration["directories"]["vector_images"] = input(" [3/8] Which folder should manim find vector images (.svg .xdv) in (optional): ")
|
||||||
|
configuration["directories"]["sounds"] = input(" [4/8] Which folder should manim find sound files (.mp3 .wav) in (optional): ")
|
||||||
|
configuration["directories"]["temporary_storage"] = input(" [5/8] Which folder should manim storage temporary files: ")
|
||||||
|
|
||||||
|
print("\n tex:")
|
||||||
|
tex = input(" [6/8] Which executable file to use to compile [latex/xelatex]: ")
|
||||||
|
if tex == "latex":
|
||||||
|
configuration["tex"]["executable"] = "latex"
|
||||||
|
configuration["tex"]["template_file"] = "tex_template.tex"
|
||||||
|
configuration["tex"]["intermediate_filetype"] = "dvi"
|
||||||
|
else:
|
||||||
|
configuration["tex"]["executable"] = "xelatex -no-pdf"
|
||||||
|
configuration["tex"]["template_file"] = "ctex_template.tex"
|
||||||
|
configuration["tex"]["intermediate_filetype"] = "xdv"
|
||||||
|
|
||||||
|
print("\n style:")
|
||||||
|
configuration["style"]["background_color"] = input(" [7/8] Which background color do you want (hex code): ")
|
||||||
|
|
||||||
|
print("\n camera_qualities:")
|
||||||
|
print(" Four defined qualities: low: 480p15 medium: 720p30 high: 1080p60 ultra_high: 2160p60")
|
||||||
|
configuration["camera_qualities"]["default_quality"] = input(" [8/8] Which one to choose as the default rendering quality [low/medium/high/ultra_high]: ")
|
||||||
|
|
||||||
|
with open(file_name, 'w', encoding="utf_8") as file:
|
||||||
|
yaml.dump(configuration, file)
|
||||||
|
|
||||||
|
print(f"\nYou have set up a {scope} configuration file")
|
||||||
|
print(f"You can manually modify it again in: {file_name}\n")
|
Loading…
Add table
Reference in a new issue