mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Merge custom defaults recursively rather than overriding manim's with the local one
This commit is contained in:
parent
f91c81dd6a
commit
e218105f73
3 changed files with 25 additions and 15 deletions
16
README.md
16
README.md
|
@ -21,10 +21,10 @@ If you want to hack on manimlib itself, clone this repository and in that direct
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# Install python requirements
|
# Install python requirements
|
||||||
pip3 install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
# Try it out
|
# Try it out
|
||||||
python3 -m manim example_scenes.py OpeningManimExample
|
python -m manim example_scenes.py OpeningManimExample
|
||||||
```
|
```
|
||||||
|
|
||||||
### Directly (Windows)
|
### Directly (Windows)
|
||||||
|
@ -34,8 +34,8 @@ python3 -m manim example_scenes.py OpeningManimExample
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/3b1b/manim.git
|
git clone https://github.com/3b1b/manim.git
|
||||||
cd manim
|
cd manim
|
||||||
pip3 install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
python3 manim.py example_scenes.py OpeningManimExample
|
python manim.py example_scenes.py OpeningManimExample
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,14 +50,14 @@ After installing `virtualenv` and `virtualenvwrapper`
|
||||||
```sh
|
```sh
|
||||||
git clone https://github.com/3b1b/manim.git
|
git clone https://github.com/3b1b/manim.git
|
||||||
mkvirtualenv -a manim -r requirements.txt manim
|
mkvirtualenv -a manim -r requirements.txt manim
|
||||||
python3 -m manim example_scenes.py OpeningManimExample
|
python -m manim example_scenes.py OpeningManimExample
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Using manim
|
## Using manim
|
||||||
Try running the following:
|
Try running the following:
|
||||||
```sh
|
```sh
|
||||||
python3 -m manim example_scenes.py OpeningManimExample
|
python -m manim example_scenes.py OpeningManimExample
|
||||||
```
|
```
|
||||||
This should pop up a window playing a simple scene.
|
This should pop up a window playing a simple scene.
|
||||||
|
|
||||||
|
@ -65,11 +65,11 @@ Some useful flags include:
|
||||||
* `-w` to write the scene to a file
|
* `-w` to write the scene to a file
|
||||||
* `-o` to write the scene to a file and open the result
|
* `-o` to write the scene to a file and open the result
|
||||||
* `-s` to skip to the end and just show the final frame.
|
* `-s` to skip to the end and just show the final frame.
|
||||||
* `-so` will asve the final frame to an image and show it
|
* `-so` will save the final frame to an image and show it
|
||||||
* `-n <number>` to skip ahead to the `n`'th animation of a scene.
|
* `-n <number>` to skip ahead to the `n`'th animation of a scene.
|
||||||
* `-f` to make the playback window fullscreen
|
* `-f` to make the playback window fullscreen
|
||||||
|
|
||||||
Take a look at custom_defaults.yml for further configuration. For example, 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. If you have a file name "custom_defaults.yml" in the same directory where you are calling manim, it will look to the configuration of that file instead of the one in manim itself.
|
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.
|
||||||
|
|
||||||
Look through [https://github.com/3b1b/videos](https://github.com/3b1b/videos) to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility with those old projects. 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.
|
Look through [https://github.com/3b1b/videos](https://github.com/3b1b/videos) to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility with those old projects. 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.
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@ import sys
|
||||||
import yaml
|
import yaml
|
||||||
from screeninfo import get_monitors
|
from screeninfo import get_monitors
|
||||||
|
|
||||||
|
from manimlib.utils.config_ops import merge_dicts_recursively
|
||||||
|
|
||||||
|
|
||||||
def parse_cli():
|
def parse_cli():
|
||||||
try:
|
try:
|
||||||
|
@ -147,14 +149,22 @@ def get_module(file_name):
|
||||||
|
|
||||||
|
|
||||||
def get_custom_defaults():
|
def get_custom_defaults():
|
||||||
# See if there's a custom_defaults file in current directory,
|
|
||||||
# otherwise fall back on the one in manimlib
|
|
||||||
filename = "custom_defaults.yml"
|
filename = "custom_defaults.yml"
|
||||||
if not os.path.exists(filename):
|
manim_defaults_file = os.path.join(get_manim_dir(), filename)
|
||||||
filename = os.path.join(get_manim_dir(), filename)
|
with open(manim_defaults_file, "r") as file:
|
||||||
|
|
||||||
with open(filename, "r") as file:
|
|
||||||
custom_defaults = yaml.safe_load(file)
|
custom_defaults = 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,
|
||||||
|
local_defaults,
|
||||||
|
)
|
||||||
|
|
||||||
return custom_defaults
|
return custom_defaults
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ class SingleStringTex(VMobject):
|
||||||
"font_size": 48,
|
"font_size": 48,
|
||||||
"height": None,
|
"height": None,
|
||||||
"organize_left_to_right": False,
|
"organize_left_to_right": False,
|
||||||
"alignment": "", # Could be "\\centering",
|
"alignment": "\\centering",
|
||||||
"math_mode": True,
|
"math_mode": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue