mirror of
https://github.com/3b1b/manim.git
synced 2025-07-29 13:03:31 +08:00
rename custom_defaults -> custom_config defaults -> default_config
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@ -147,5 +147,5 @@ dmypy.json
|
||||
|
||||
# For manim
|
||||
/videos
|
||||
/custom_defaults.yml
|
||||
/manimlib/defaults.yml
|
||||
/custom_config.yml
|
||||
/manimlib/default_config.yml
|
@ -90,7 +90,7 @@ Some useful flags include:
|
||||
* `-n <number>` to skip ahead to the `n`'th animation of a scene.
|
||||
* `-f` to make the playback window fullscreen
|
||||
|
||||
Take a look at custom_defaults.yml for further configuration. To add your customization, you can either edit this file, or add another file by the same name "custom_defaults.yml" to whatever directory you are running manim from. For example [this is the one](https://github.com/3b1b/videos/blob/master/custom_defaults.yml) for 3blue1brown videos. There you can specify where videos should be output to, where manim should look for image files and sounds you want to read in, and other defaults regarding style and video quality.
|
||||
Take a look at custom_config.yml for further configuration. To add your customization, you can either edit this file, or add another file by the same name "custom_config.yml" to whatever directory you are running manim from. For example [this is the one](https://github.com/3b1b/videos/blob/master/custom_config.yml) for 3blue1brown videos. There you can specify where videos should be output to, where manim should look for image files and sounds you want to read in, and other defaults regarding style and video quality.
|
||||
|
||||
Look through the [example scenes](https://3b1b.github.io/manim/getting_started/example_scenes.html) to get a sense of how it is used, and feel free to look through the code behind [3blue1brown videos](https://github.com/3b1b/videos) for a much larger set of example. Note, however, that developments are often made to the library without considering backwards compatibility with those old videos. To run an old project with a guarantee that it will work, you will have to go back to the commit which completed that project.
|
||||
|
||||
|
@ -355,7 +355,7 @@ SurfaceExample
|
||||
# be interpreted as the side towards the light, and away from
|
||||
# the light. These can be either urls, or paths to a local file
|
||||
# in whatever you've set as the image directory in
|
||||
# the custom_defaults.yml file
|
||||
# the custom_config.yml file
|
||||
|
||||
# day_texture = "EarthTextureMap"
|
||||
# night_texture = "NightEarthTextureMap"
|
||||
|
@ -380,7 +380,7 @@ class SurfaceExample(Scene):
|
||||
# be interpreted as the side towards the light, and away from
|
||||
# the light. These can be either urls, or paths to a local file
|
||||
# in whatever you've set as the image directory in
|
||||
# the custom_defaults.yml file
|
||||
# the custom_config.yml file
|
||||
|
||||
# day_texture = "EarthTextureMap"
|
||||
# night_texture = "NightEarthTextureMap"
|
||||
|
@ -156,9 +156,9 @@ def get_module(file_name):
|
||||
return module
|
||||
|
||||
|
||||
def get_custom_defaults():
|
||||
filename = "custom_defaults.yml"
|
||||
global_defaults_file = os.path.join(get_manim_dir(), "manimlib", "defaults.yml")
|
||||
def get_custom_config():
|
||||
filename = "custom_config.yml"
|
||||
global_defaults_file = os.path.join(get_manim_dir(), "manimlib", "default_config.yml")
|
||||
|
||||
if not (os.path.exists(global_defaults_file) or os.path.exists(filename)):
|
||||
print("There is no configuration file detected. Initial configuration:\n")
|
||||
@ -166,27 +166,29 @@ def get_custom_defaults():
|
||||
|
||||
if os.path.exists(global_defaults_file):
|
||||
with open(global_defaults_file, "r") as file:
|
||||
custom_defaults = yaml.safe_load(file)
|
||||
else:
|
||||
with open(filename, "r") as file:
|
||||
local_defaults = yaml.safe_load(file)
|
||||
config = yaml.safe_load(file)
|
||||
|
||||
# See if there's a custom_defaults file in current directory,
|
||||
# and if so, it further updates the defaults based on it.
|
||||
if os.path.exists(filename):
|
||||
with open(filename, "r") as file:
|
||||
local_defaults = yaml.safe_load(file)
|
||||
if local_defaults:
|
||||
custom_defaults = merge_dicts_recursively(
|
||||
custom_defaults,
|
||||
config = merge_dicts_recursively(
|
||||
config,
|
||||
local_defaults,
|
||||
)
|
||||
|
||||
return custom_defaults
|
||||
else:
|
||||
with open(filename, "r") as file:
|
||||
config = yaml.safe_load(file)
|
||||
|
||||
# See if there's a custom_config file in current directory,
|
||||
# and if so, it further updates the defaults based on it.
|
||||
|
||||
return config
|
||||
|
||||
|
||||
def get_configuration(args):
|
||||
custom_defaults = get_custom_defaults()
|
||||
custom_config = get_custom_config()
|
||||
|
||||
write_file = any([args.write_file, args.open, args.finder])
|
||||
if args.transparent:
|
||||
@ -198,14 +200,14 @@ def get_configuration(args):
|
||||
|
||||
file_writer_config = {
|
||||
"write_to_movie": not args.skip_animations and write_file,
|
||||
"break_into_partial_movies": custom_defaults["break_into_partial_movies"],
|
||||
"break_into_partial_movies": custom_config["break_into_partial_movies"],
|
||||
"save_last_frame": args.skip_animations and write_file,
|
||||
"save_pngs": args.save_pngs,
|
||||
# If -t is passed in (for transparent), this will be RGBA
|
||||
"png_mode": "RGBA" if args.transparent else "RGB",
|
||||
"movie_file_extension": file_ext,
|
||||
"mirror_module_path": custom_defaults["directories"]["mirror_module_path"],
|
||||
"output_directory": args.video_dir or custom_defaults["directories"]["output"],
|
||||
"mirror_module_path": custom_config["directories"]["mirror_module_path"],
|
||||
"output_directory": args.video_dir or custom_config["directories"]["output"],
|
||||
"file_name": args.file_name,
|
||||
"input_file_path": args.file or "",
|
||||
"open_file_upon_completion": args.open,
|
||||
@ -227,7 +229,7 @@ def get_configuration(args):
|
||||
}
|
||||
|
||||
# Camera configuration
|
||||
config["camera_config"] = get_camera_configuration(args, custom_defaults)
|
||||
config["camera_config"] = get_camera_configuration(args, custom_config)
|
||||
|
||||
# Default to putting window in the upper right of screen,
|
||||
# but make it full screen if -f is passed in
|
||||
@ -257,9 +259,9 @@ def get_configuration(args):
|
||||
return config
|
||||
|
||||
|
||||
def get_camera_configuration(args, custom_defaults):
|
||||
def get_camera_configuration(args, custom_config):
|
||||
camera_config = {}
|
||||
camera_qualities = get_custom_defaults()["camera_qualities"]
|
||||
camera_qualities = get_custom_config()["camera_qualities"]
|
||||
if args.low_quality:
|
||||
quality = camera_qualities["low"]
|
||||
elif args.medium_quality:
|
||||
@ -287,7 +289,7 @@ def get_camera_configuration(args, custom_defaults):
|
||||
})
|
||||
|
||||
try:
|
||||
bg_color = args.color or custom_defaults["style"]["background_color"]
|
||||
bg_color = args.color or custom_config["style"]["background_color"]
|
||||
camera_config["background_color"] = colour.Color(bg_color)
|
||||
except AttributeError as err:
|
||||
print("Please use a valid color")
|
||||
|
@ -3,12 +3,12 @@ import sys
|
||||
import logging
|
||||
|
||||
from manimlib.scene.scene import Scene
|
||||
from manimlib.config import get_custom_defaults
|
||||
from manimlib.config import get_custom_config
|
||||
|
||||
|
||||
class BlankScene(Scene):
|
||||
def construct(self):
|
||||
exec(get_custom_defaults()["universal_import_line"])
|
||||
exec(get_custom_config()["universal_import_line"])
|
||||
self.embed()
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
from manimlib.config import get_custom_defaults
|
||||
from manimlib.config import get_custom_config
|
||||
from manimlib.config import get_manim_dir
|
||||
|
||||
CUSTOMIZATION = {}
|
||||
@ -9,7 +9,7 @@ CUSTOMIZATION = {}
|
||||
|
||||
def get_customization():
|
||||
if not CUSTOMIZATION:
|
||||
CUSTOMIZATION.update(get_custom_defaults())
|
||||
CUSTOMIZATION.update(get_custom_config())
|
||||
directories = CUSTOMIZATION["directories"]
|
||||
# Unless user has specified otherwise, use the system default temp
|
||||
# directory for storing tex files, mobject_data, etc.
|
||||
|
@ -48,9 +48,9 @@ def init_customization():
|
||||
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")
|
||||
file_name = os.path.join(get_manim_dir(), "manimlib", "default_config.yml")
|
||||
else:
|
||||
file_name = os.path.join(os.getcwd(), "custom_defaults.yml")
|
||||
file_name = os.path.join(os.getcwd(), "custom_config.yml")
|
||||
|
||||
print("\n directories:")
|
||||
configuration["directories"]["output"] = input(" [1/8] Where should manim output video and image files place: ")
|
||||
|
@ -6,7 +6,7 @@ from contextlib import contextmanager
|
||||
|
||||
from manimlib.utils.directories import get_tex_dir
|
||||
from manimlib.config import get_manim_dir
|
||||
from manimlib.config import get_custom_defaults
|
||||
from manimlib.config import get_custom_config
|
||||
|
||||
|
||||
SAVED_TEX_CONFIG = {}
|
||||
@ -25,8 +25,8 @@ def get_tex_config():
|
||||
"""
|
||||
# Only load once, then save thereafter
|
||||
if not SAVED_TEX_CONFIG:
|
||||
custom_defaults = get_custom_defaults()
|
||||
SAVED_TEX_CONFIG.update(custom_defaults["tex"])
|
||||
custom_config = get_custom_config()
|
||||
SAVED_TEX_CONFIG.update(custom_config["tex"])
|
||||
# Read in template file
|
||||
template_filename = os.path.join(
|
||||
get_manim_dir(), "manimlib", "tex_templates",
|
||||
|
Reference in New Issue
Block a user