From 2394bdc2e62cdacdb482c5b7b69a2880598f5a5f Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sun, 7 Feb 2021 17:43:05 +0800 Subject: [PATCH 01/15] refactor __init__.py and __main__.py --- custom_defaults.yml | 2 +- example_scenes.py | 2 +- manimlib/__init__.py | 96 ++++++++++++++++++++++++++++++++++---- manimlib/__main__.py | 12 +++++ manimlib/defaults.yml | 2 +- manimlib/imports.py | 106 ------------------------------------------ setup.cfg | 4 +- 7 files changed, 104 insertions(+), 120 deletions(-) create mode 100644 manimlib/__main__.py delete mode 100644 manimlib/imports.py diff --git a/custom_defaults.yml b/custom_defaults.yml index d34236ae..45b3b77b 100644 --- a/custom_defaults.yml +++ b/custom_defaults.yml @@ -25,7 +25,7 @@ tex: # executable: "xelatex -no-pdf" # template_file: "ctex_template.tex" # intermediate_filetype: "xdv" -universal_import_line: "from manimlib.imports import *" +universal_import_line: "from manimlib import *" style: font: "Consolas" background_color: "#333333" diff --git a/example_scenes.py b/example_scenes.py index 666faa42..f881a1b5 100644 --- a/example_scenes.py +++ b/example_scenes.py @@ -1,4 +1,4 @@ -from manimlib.imports import * +from manimlib import * # To watch one of these scenes, run the following: # python -m manim example_scenes.py SquareToCircle diff --git a/manimlib/__init__.py b/manimlib/__init__.py index 9b3b3f28..a03b7b89 100644 --- a/manimlib/__init__.py +++ b/manimlib/__init__.py @@ -1,12 +1,90 @@ -#!/usr/bin/env python -import manimlib.config -import manimlib.extract_scene +from manimlib.constants import * +from manimlib.animation.animation import * +from manimlib.animation.composition import * +from manimlib.animation.creation import * +from manimlib.animation.fading import * +from manimlib.animation.growing import * +from manimlib.animation.indication import * +from manimlib.animation.movement import * +from manimlib.animation.numbers import * +from manimlib.animation.rotation import * +from manimlib.animation.specialized import * +from manimlib.animation.transform import * +from manimlib.animation.transform_matching_parts import * +from manimlib.animation.update import * -def main(): - args = manimlib.config.parse_cli() - config = manimlib.config.get_configuration(args) - scenes = manimlib.extract_scene.main(config) +from manimlib.camera.camera import * - for scene in scenes: - scene.run() +from manimlib.mobject.coordinate_systems import * +from manimlib.mobject.changing import * +from manimlib.mobject.frame import * +from manimlib.mobject.functions import * +from manimlib.mobject.geometry import * +from manimlib.mobject.matrix import * +from manimlib.mobject.mobject import * +from manimlib.mobject.number_line import * +from manimlib.mobject.numbers import * +from manimlib.mobject.probability import * +from manimlib.mobject.shape_matchers import * +from manimlib.mobject.interactive import * +from manimlib.mobject.svg.brace import * +from manimlib.mobject.svg.drawings import * +from manimlib.mobject.svg.svg_mobject import * +from manimlib.mobject.svg.tex_mobject import * +from manimlib.mobject.svg.text_mobject import * +from manimlib.mobject.three_dimensions import * +from manimlib.mobject.types.image_mobject import * +from manimlib.mobject.types.point_cloud_mobject import * +from manimlib.mobject.types.surface import * +from manimlib.mobject.types.vectorized_mobject import * +from manimlib.mobject.types.dot_cloud import * +from manimlib.mobject.mobject_update_utils import * +from manimlib.mobject.value_tracker import * +from manimlib.mobject.vector_field import * + +from manimlib.once_useful_constructs.arithmetic import * +from manimlib.once_useful_constructs.combinatorics import * +from manimlib.once_useful_constructs.complex_transformation_scene import * +from manimlib.once_useful_constructs.counting import * +from manimlib.once_useful_constructs.fractals import * +from manimlib.once_useful_constructs.graph_theory import * +from manimlib.once_useful_constructs.light import * + +from manimlib.scene.scene import * +from manimlib.scene.sample_space_scene import * +from manimlib.scene.three_d_scene import * +from manimlib.scene.vector_space_scene import * + +from manimlib.utils.bezier import * +from manimlib.utils.color import * +from manimlib.utils.config_ops import * +from manimlib.utils.customization import * +from manimlib.utils.debug import * +from manimlib.utils.directories import * +from manimlib.utils.images import * +from manimlib.utils.iterables import * +from manimlib.utils.file_ops import * +from manimlib.utils.paths import * +from manimlib.utils.rate_functions import * +from manimlib.utils.simple_functions import * +from manimlib.utils.sounds import * +from manimlib.utils.space_ops import * +from manimlib.utils.strings import * + +# Non manim libraries that are also nice to have without thinking + +import inspect +import itertools as it +import numpy as np +import operator as op +import os +import random +import re +import string +import sys +import math +import sympy + +from PIL import Image +from colour import Color diff --git a/manimlib/__main__.py b/manimlib/__main__.py new file mode 100644 index 00000000..9b3b3f28 --- /dev/null +++ b/manimlib/__main__.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python +import manimlib.config +import manimlib.extract_scene + + +def main(): + args = manimlib.config.parse_cli() + config = manimlib.config.get_configuration(args) + scenes = manimlib.extract_scene.main(config) + + for scene in scenes: + scene.run() diff --git a/manimlib/defaults.yml b/manimlib/defaults.yml index 7b89767c..c63ff796 100644 --- a/manimlib/defaults.yml +++ b/manimlib/defaults.yml @@ -25,7 +25,7 @@ tex: # executable: "xelatex -no-pdf" # template_file: "ctex_template.tex" # intermediate_filetype: "xdv" -universal_import_line: "from manimlib.imports import *" +universal_import_line: "from manimlib import *" style: font: "Consolas" background_color: "#333333" diff --git a/manimlib/imports.py b/manimlib/imports.py deleted file mode 100644 index 2237bfaf..00000000 --- a/manimlib/imports.py +++ /dev/null @@ -1,106 +0,0 @@ -""" -I won't pretend like this is best practice, but in creating animations for a video, -it can be very nice to simply have all of the Mobjects, Animations, Scenes, etc. -of manim available without having to worry about what namespace they come from. - -Rather than having a large pile of "from import *" at the top of every such -script, the intent of this file is to make it so that one can just include -"from manimlib.imports import *". The effects of adding more modules -or refactoring the library on current or older scene scripts should be entirely -addressible by changing this file. - -Note: One should NOT import from this file for main library code, it is meant only -as a convenience for scripts creating scenes for videos. -""" - - -from manimlib.constants import * - -from manimlib.animation.animation import * -from manimlib.animation.composition import * -from manimlib.animation.creation import * -from manimlib.animation.fading import * -from manimlib.animation.growing import * -from manimlib.animation.indication import * -from manimlib.animation.movement import * -from manimlib.animation.numbers import * -from manimlib.animation.rotation import * -from manimlib.animation.specialized import * -from manimlib.animation.transform import * -from manimlib.animation.transform_matching_parts import * -from manimlib.animation.update import * - -from manimlib.camera.camera import * - -from manimlib.mobject.coordinate_systems import * -from manimlib.mobject.changing import * -from manimlib.mobject.frame import * -from manimlib.mobject.functions import * -from manimlib.mobject.geometry import * -from manimlib.mobject.matrix import * -from manimlib.mobject.mobject import * -from manimlib.mobject.number_line import * -from manimlib.mobject.numbers import * -from manimlib.mobject.probability import * -from manimlib.mobject.shape_matchers import * -from manimlib.mobject.interactive import * -from manimlib.mobject.svg.brace import * -from manimlib.mobject.svg.drawings import * -from manimlib.mobject.svg.svg_mobject import * -from manimlib.mobject.svg.tex_mobject import * -from manimlib.mobject.svg.text_mobject import * -from manimlib.mobject.three_dimensions import * -from manimlib.mobject.types.image_mobject import * -from manimlib.mobject.types.point_cloud_mobject import * -from manimlib.mobject.types.surface import * -from manimlib.mobject.types.vectorized_mobject import * -from manimlib.mobject.types.dot_cloud import * -from manimlib.mobject.mobject_update_utils import * -from manimlib.mobject.value_tracker import * -from manimlib.mobject.vector_field import * - -from manimlib.once_useful_constructs.arithmetic import * -from manimlib.once_useful_constructs.combinatorics import * -from manimlib.once_useful_constructs.complex_transformation_scene import * -from manimlib.once_useful_constructs.counting import * -from manimlib.once_useful_constructs.fractals import * -from manimlib.once_useful_constructs.graph_theory import * -from manimlib.once_useful_constructs.light import * - -from manimlib.scene.scene import * -from manimlib.scene.sample_space_scene import * -from manimlib.scene.three_d_scene import * -from manimlib.scene.vector_space_scene import * - -from manimlib.utils.bezier import * -from manimlib.utils.color import * -from manimlib.utils.config_ops import * -from manimlib.utils.customization import * -from manimlib.utils.debug import * -from manimlib.utils.directories import * -from manimlib.utils.images import * -from manimlib.utils.iterables import * -from manimlib.utils.file_ops import * -from manimlib.utils.paths import * -from manimlib.utils.rate_functions import * -from manimlib.utils.simple_functions import * -from manimlib.utils.sounds import * -from manimlib.utils.space_ops import * -from manimlib.utils.strings import * - -# Non manim libraries that are also nice to have without thinking - -import inspect -import itertools as it -import numpy as np -import operator as op -import os -import random -import re -import string -import sys -import math -import sympy - -from PIL import Image -from colour import Color diff --git a/setup.cfg b/setup.cfg index 956d6556..73f4db16 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,5 +19,5 @@ extra_files = requirements.txt [entry_points] console_scripts = - manimgl = manimlib:main - manim-render = manimlib:main + manimgl = manimlib.__main__:main + manim-render = manimlib.__main__:main From e3d09d161c0742e37c1994dbbcd8a0a447339cb0 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sun, 7 Feb 2021 17:45:18 +0800 Subject: [PATCH 02/15] add auto config guide --- custom_defaults.yml | 56 ----------------------- manimlib/__main__.py | 15 ++++--- manimlib/config.py | 21 +++++++-- manimlib/defaults.yml | 56 ----------------------- manimlib/utils/init_config.py | 84 +++++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+), 120 deletions(-) delete mode 100644 custom_defaults.yml delete mode 100644 manimlib/defaults.yml create mode 100644 manimlib/utils/init_config.py diff --git a/custom_defaults.yml b/custom_defaults.yml deleted file mode 100644 index 45b3b77b..00000000 --- a/custom_defaults.yml +++ /dev/null @@ -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" diff --git a/manimlib/__main__.py b/manimlib/__main__.py index 9b3b3f28..9bc76578 100644 --- a/manimlib/__main__.py +++ b/manimlib/__main__.py @@ -1,12 +1,17 @@ #!/usr/bin/env python import manimlib.config import manimlib.extract_scene +import manimlib.utils.init_config def main(): args = manimlib.config.parse_cli() - config = manimlib.config.get_configuration(args) - scenes = manimlib.extract_scene.main(config) - - for scene in scenes: - scene.run() + + if args.config: + manimlib.utils.init_config.init_customization() + else: + config = manimlib.config.get_configuration(args) + scenes = manimlib.extract_scene.main(config) + + for scene in scenes: + scene.run() diff --git a/manimlib/config.py b/manimlib/config.py index b1411965..583d26bb 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -8,6 +8,7 @@ import yaml from screeninfo import get_monitors from manimlib.utils.config_ops import merge_dicts_recursively +from manimlib.utils.init_config import init_customization def parse_cli(): @@ -98,6 +99,11 @@ def parse_cli(): "--file_name", help="Name for the movie or image file", ) + parser.add_argument( + "--config", + action="store_true", + help="Guide for automatic configuration", + ) parser.add_argument( "-n", "--start_at_animation_number", help="Start rendering not from the first animation, but" @@ -152,9 +158,18 @@ def get_module(file_name): def get_custom_defaults(): filename = "custom_defaults.yml" - manim_defaults_file = os.path.join(get_manim_dir(), "manimlib", "defaults.yml") - with open(manim_defaults_file, "r") as file: - custom_defaults = yaml.safe_load(file) + global_defaults_file = os.path.join(get_manim_dir(), "manimlib", "defaults.yml") + + 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) + else: + with open(filename, "r") as file: + local_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. diff --git a/manimlib/defaults.yml b/manimlib/defaults.yml deleted file mode 100644 index c63ff796..00000000 --- a/manimlib/defaults.yml +++ /dev/null @@ -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" diff --git a/manimlib/utils/init_config.py b/manimlib/utils/init_config.py new file mode 100644 index 00000000..c94fc46f --- /dev/null +++ b/manimlib/utils/init_config.py @@ -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") From 3fa68ad60c0c800ebd5edb7b5afaa890d73c074a Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sun, 7 Feb 2021 17:46:33 +0800 Subject: [PATCH 03/15] add config file to .gitignore --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f10a0816..f19cb13b 100644 --- a/.gitignore +++ b/.gitignore @@ -145,5 +145,7 @@ dmypy.json # Custom exclusions: .DS_Store -# -/videos \ No newline at end of file +# For manim +/videos +/custom_defaults.yml +/manimlib/defaults.yml \ No newline at end of file From cbe016391b2db444f758b0c2fe2cc49c5fea81f5 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sun, 7 Feb 2021 17:48:51 +0800 Subject: [PATCH 04/15] delete old entry point file and add __init__ for folders --- manim.py | 5 ----- manimlib/animation/__init__.py | 0 manimlib/camera/__init__.py | 0 manimlib/mobject/__init__.py | 0 manimlib/mobject/svg/__init__.py | 0 manimlib/mobject/types/__init__.py | 0 manimlib/once_useful_constructs/__init__.py | 0 manimlib/scene/__init__.py | 0 manimlib/utils/__init__.py | 0 9 files changed, 5 deletions(-) delete mode 100755 manim.py create mode 100644 manimlib/animation/__init__.py create mode 100644 manimlib/camera/__init__.py create mode 100644 manimlib/mobject/__init__.py create mode 100644 manimlib/mobject/svg/__init__.py create mode 100644 manimlib/mobject/types/__init__.py create mode 100644 manimlib/once_useful_constructs/__init__.py create mode 100644 manimlib/scene/__init__.py create mode 100644 manimlib/utils/__init__.py diff --git a/manim.py b/manim.py deleted file mode 100755 index 2bebaea6..00000000 --- a/manim.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python -import manimlib - -if __name__ == "__main__": - manimlib.main() diff --git a/manimlib/animation/__init__.py b/manimlib/animation/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/camera/__init__.py b/manimlib/camera/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/mobject/__init__.py b/manimlib/mobject/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/mobject/svg/__init__.py b/manimlib/mobject/svg/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/mobject/types/__init__.py b/manimlib/mobject/types/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/once_useful_constructs/__init__.py b/manimlib/once_useful_constructs/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/scene/__init__.py b/manimlib/scene/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/manimlib/utils/__init__.py b/manimlib/utils/__init__.py new file mode 100644 index 00000000..e69de29b From 00fe33957c8662588a680c64f5bdbf01eda09b88 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sun, 7 Feb 2021 21:38:19 +0800 Subject: [PATCH 05/15] rename custom_defaults -> custom_config defaults -> default_config --- .gitignore | 4 +- README.md | 2 +- .../source/getting_started/example_scenes.rst | 2 +- example_scenes.py | 2 +- manimlib/config.py | 50 ++++++++++--------- manimlib/extract_scene.py | 4 +- manimlib/utils/customization.py | 4 +- manimlib/utils/init_config.py | 4 +- manimlib/utils/tex_file_writing.py | 6 +-- 9 files changed, 40 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index f19cb13b..0dd14596 100644 --- a/.gitignore +++ b/.gitignore @@ -147,5 +147,5 @@ dmypy.json # For manim /videos -/custom_defaults.yml -/manimlib/defaults.yml \ No newline at end of file +/custom_config.yml +/manimlib/default_config.yml \ No newline at end of file diff --git a/README.md b/README.md index 86b6f346..d74f0466 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Some useful flags include: * `-n ` 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. diff --git a/docs/source/getting_started/example_scenes.rst b/docs/source/getting_started/example_scenes.rst index e33efd0b..efc6c16c 100644 --- a/docs/source/getting_started/example_scenes.rst +++ b/docs/source/getting_started/example_scenes.rst @@ -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" diff --git a/example_scenes.py b/example_scenes.py index f881a1b5..4dddbf4c 100644 --- a/example_scenes.py +++ b/example_scenes.py @@ -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" diff --git a/manimlib/config.py b/manimlib/config.py index 583d26bb..2970b478 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -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) + config = yaml.safe_load(file) + + if os.path.exists(filename): + with open(filename, "r") as file: + local_defaults = yaml.safe_load(file) + if local_defaults: + config = merge_dicts_recursively( + config, + local_defaults, + ) + 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, + # See if there's a custom_config 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 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") diff --git a/manimlib/extract_scene.py b/manimlib/extract_scene.py index 7a537769..6036765f 100644 --- a/manimlib/extract_scene.py +++ b/manimlib/extract_scene.py @@ -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() diff --git a/manimlib/utils/customization.py b/manimlib/utils/customization.py index 333a41c6..bf79b1b8 100644 --- a/manimlib/utils/customization.py +++ b/manimlib/utils/customization.py @@ -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. diff --git a/manimlib/utils/init_config.py b/manimlib/utils/init_config.py index c94fc46f..064db879 100644 --- a/manimlib/utils/init_config.py +++ b/manimlib/utils/init_config.py @@ -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: ") diff --git a/manimlib/utils/tex_file_writing.py b/manimlib/utils/tex_file_writing.py index 77716986..4d76d300 100644 --- a/manimlib/utils/tex_file_writing.py +++ b/manimlib/utils/tex_file_writing.py @@ -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", From 36107c28ef8a02882552cb2ca96466aea7f29718 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Sun, 7 Feb 2021 21:43:20 +0800 Subject: [PATCH 06/15] update README --- README.md | 16 +++++++++------- docs/source/getting_started/installation.rst | 10 ++++++---- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d74f0466..98bf3528 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,12 @@ If you want to hack on manimlib itself, clone this repository and in that direct ```sh # Install python requirements -pip install -r requirements.txt +pip install -e . # Try it out -python manim.py example_scenes.py OpeningManimExample +manimgl example_scenes.py OpeningManimExample +# or +manim-render example_scenes.py OpeningManimExample ``` ### Mac OSX 1. Install FFmpeg, LaTeX, Cairo in terminal using homebrew. @@ -44,8 +46,8 @@ python manim.py example_scenes.py OpeningManimExample ```sh git clone https://github.com/3b1b/manim.git cd manim - pip install -r requirements.txt - python manim.py example_scenes.py OpeningManimExample + pip install -e . + manimgl example_scenes.py OpeningManimExample ``` ### Directly (Windows) @@ -55,8 +57,8 @@ python manim.py example_scenes.py OpeningManimExample ```sh git clone https://github.com/3b1b/manim.git cd manim - pip install -r requirements.txt - python manim.py example_scenes.py OpeningManimExample + pip install -e . + manimgl example_scenes.py OpeningManimExample ``` @@ -78,7 +80,7 @@ python -m manim example_scenes.py OpeningManimExample ## Using manim Try running the following: ```sh -python -m manim example_scenes.py OpeningManimExample +manimgl example_scenes.py OpeningManimExample ``` This should pop up a window playing a simple scene. diff --git a/docs/source/getting_started/installation.rst b/docs/source/getting_started/installation.rst index 01cb7a65..06253786 100644 --- a/docs/source/getting_started/installation.rst +++ b/docs/source/getting_started/installation.rst @@ -19,10 +19,12 @@ that directory execute: .. code-block:: sh # Install python requirements - pip install -r requirements.txt + pip install -e . # Try it out - python -m manim example_scenes.py OpeningManimExample + manimgl example_scenes.py OpeningManimExample + # or + manim-render example_scenes.py OpeningManimExample If you run the above command and no error message appears, then you have successfully installed all the environments required by manim. @@ -40,8 +42,8 @@ Directly (Windows) git clone https://github.com/3b1b/manim.git cd manim - pip install -r requirements.txt - python manim.py example_scenes.py OpeningManimExample + pip install -e . + manimgl example_scenes.py OpeningManimExample For Anaconda ------------ From 69235f0a214c358d0f4f92342e3ac9adf1f4be6e Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 09:55:30 +0800 Subject: [PATCH 07/15] remove non-manim lib in __init__.py --- manimlib/__init__.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/manimlib/__init__.py b/manimlib/__init__.py index a03b7b89..b440aaa3 100644 --- a/manimlib/__init__.py +++ b/manimlib/__init__.py @@ -71,20 +71,3 @@ from manimlib.utils.simple_functions import * from manimlib.utils.sounds import * from manimlib.utils.space_ops import * from manimlib.utils.strings import * - -# Non manim libraries that are also nice to have without thinking - -import inspect -import itertools as it -import numpy as np -import operator as op -import os -import random -import re -import string -import sys -import math -import sympy - -from PIL import Image -from colour import Color From 47d4b0236ee1629db41a7baa39c63d5718a326bf Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 10:29:18 +0800 Subject: [PATCH 08/15] readd default_config and improve config guide --- .gitignore | 3 +- manimlib/config.py | 15 +++++++--- manimlib/default_config.yml | 56 +++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 6 deletions(-) create mode 100644 manimlib/default_config.yml diff --git a/.gitignore b/.gitignore index 0dd14596..346a56ca 100644 --- a/.gitignore +++ b/.gitignore @@ -147,5 +147,4 @@ dmypy.json # For manim /videos -/custom_config.yml -/manimlib/default_config.yml \ No newline at end of file +/custom_config.yml \ No newline at end of file diff --git a/manimlib/config.py b/manimlib/config.py index 2970b478..637758e0 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -160,10 +160,6 @@ 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") - init_customization() - if os.path.exists(global_defaults_file): with open(global_defaults_file, "r") as file: config = yaml.safe_load(file) @@ -188,6 +184,17 @@ def get_custom_config(): def get_configuration(args): + local_config_file = "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(local_config_file)): + print("There is no configuration file detected. Initial configuration:\n") + init_customization() + elif not os.path.exists(local_config_file): + print(f"""Warning: Using the default configuration file, which you can modify in {global_defaults_file} + If you want to create a local configuration file, you can create a file named {local_config_file}, or run manimgl --config + """) + # print(f"Warning: Using the default configuration file, which you can modify in {global_defaults_file}") + # print(f" If you want to create a local configuration file, you can create a file named {filename}") custom_config = get_custom_config() write_file = any([args.write_file, args.open, args.finder]) diff --git a/manimlib/default_config.yml b/manimlib/default_config.yml new file mode 100644 index 00000000..d34236ae --- /dev/null +++ b/manimlib/default_config.yml @@ -0,0 +1,56 @@ +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.imports 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" From 608b2d9bce545add382ceab6cc4e5b020427c1c7 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 10:46:11 +0800 Subject: [PATCH 09/15] delete comment --- manimlib/config.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/manimlib/config.py b/manimlib/config.py index 637758e0..433ea74f 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -193,8 +193,6 @@ def get_configuration(args): print(f"""Warning: Using the default configuration file, which you can modify in {global_defaults_file} If you want to create a local configuration file, you can create a file named {local_config_file}, or run manimgl --config """) - # print(f"Warning: Using the default configuration file, which you can modify in {global_defaults_file}") - # print(f" If you want to create a local configuration file, you can create a file named {filename}") custom_config = get_custom_config() write_file = any([args.write_file, args.open, args.finder]) From f0cbc0571f3b10d6ba913a6ccbe49a55ee6b71aa Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 11:42:50 +0800 Subject: [PATCH 10/15] Update README --- README.md | 20 ++++++-------------- environment.yml | 29 ----------------------------- 2 files changed, 6 insertions(+), 43 deletions(-) delete mode 100644 environment.yml diff --git a/README.md b/README.md index 98bf3528..1b8a6da3 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Note, there are two versions of manim. This repository began as a personal proj Since the fork, this version has evolved to work on top of OpenGL, and allows real-time rendering to an interactive window before scenes are finalized and written to a file. ## Installation -Manim runs on Python 3.8. +Manim runs on Python 3.6 or higher (Python 3.8 is recommended). System requirements are [FFmpeg](https://ffmpeg.org/), [OpenGL](https://www.opengl.org//), [LaTeX](https://www.latex-project.org) (optional, if you want to use LaTeX) and [cairo](https://www.cairographics.org/) (optional, if you want to use Text). @@ -28,7 +28,7 @@ For more options, take a look at the [Using manim](#using-manim) sections furthe If you want to hack on manimlib itself, clone this repository and in that directory execute: ```sh -# Install python requirements +# Install manimgl pip install -e . # Try it out @@ -61,20 +61,12 @@ manim-render example_scenes.py OpeningManimExample manimgl example_scenes.py OpeningManimExample ``` - ## Anaconda Install -* Install latex as above. -* Create a conda environment using `conda env create -f environment.yml` - - -### Using `virtualenv` and `virtualenvwrapper` -After installing `virtualenv` and `virtualenvwrapper` -```sh -git clone https://github.com/3b1b/manim.git -mkvirtualenv -a manim -r requirements.txt manim -python -m manim example_scenes.py OpeningManimExample -``` +* Install LaTeX as above. +* Create a conda environment using `conda create -n manim python=3.8`. +* Activate the environment using `conda activate manim`. +* Install manimgl using `pip install -e .`. ## Using manim diff --git a/environment.yml b/environment.yml deleted file mode 100644 index b77113f9..00000000 --- a/environment.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: manim_shaders -channels: - - defaults - - conda-forge -dependencies: - - python=3.7 - - pip - - pip: - - pyreadline - - matplotlib - - mapbox-earcut - - moderngl_window - - screeninfo - - argparse - - colour - - numpy - - Pillow - - progressbar - - scipy - - sympy - - tqdm - - moderngl - - pydub - - pyyaml - - validators - - ipython - - PyOpenGL - - pycairo - From 24d9d9e45d967a27c591b6a297299ec2ef95b8cc Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 12:04:29 +0800 Subject: [PATCH 11/15] update docs --- .../{custom_default.rst => custom_config.rst} | 14 +- docs/source/getting_started/configuration.rst | 27 +-- .../source/getting_started/example_scenes.rst | 2 +- docs/source/getting_started/installation.rst | 15 +- docs/source/getting_started/quickstart.rst | 22 +- docs/source/getting_started/structure.rst | 200 +++++++++--------- docs/source/index.rst | 2 +- 7 files changed, 137 insertions(+), 145 deletions(-) rename docs/source/documentation/{custom_default.rst => custom_config.rst} (93%) diff --git a/docs/source/documentation/custom_default.rst b/docs/source/documentation/custom_config.rst similarity index 93% rename from docs/source/documentation/custom_default.rst rename to docs/source/documentation/custom_config.rst index 554d1fa2..496c87a9 100644 --- a/docs/source/documentation/custom_default.rst +++ b/docs/source/documentation/custom_config.rst @@ -1,4 +1,4 @@ -custom_default +custom_config ============== ``directories`` @@ -18,12 +18,13 @@ custom_default file and saved the last frame, then the final directory structure will be like: .. code-block:: text - :emphasize-lines: 8, 10 + :emphasize-lines: 9, 11 manim/ ├── manimlib/ │ ├── animation/ │ ├── ... + │ ├── default_config.yml │ └── window.py ├── output/ │ ├── images @@ -31,18 +32,18 @@ custom_default │ └── videos │ └── Scene1.mp4 ├── code.py - ├── custom_default.yml - └── manim.py + └── custom_config.yml But if you set ``mirror_module_path`` to ``True``, the directory structure will be: .. code-block:: text - :emphasize-lines: 7 + :emphasize-lines: 8 manim/ ├── manimlib/ │ ├── animation/ │ ├── ... + │ ├── default_config.yml │ └── window.py ├── output/ │ └── code/ @@ -51,8 +52,7 @@ custom_default │ └── videos │ └── Scene1.mp4 ├── code.py - ├── custom_default.yml - └── manim.py + └── custom_config.yml - ``raster_images`` The directory for storing raster images to be used in the code (including diff --git a/docs/source/getting_started/configuration.rst b/docs/source/getting_started/configuration.rst index f0947097..17319bb1 100644 --- a/docs/source/getting_started/configuration.rst +++ b/docs/source/getting_started/configuration.rst @@ -4,14 +4,16 @@ CLI flags and configuration Command Line Interface ---------------------- -To run manim, you need to enter the directory at the same level as ``manim.py`` +To run manim, you need to enter the directory at the same level as ``manimlib/`` and enter the command in the following format into terminal: .. code-block:: sh - python manim.py .py + manimgl .py + # or + manim-render .py -- ``.py`` : The python file you wrote. Needs to be at the same level as ``manim.py``, otherwise you need to use an absolute path or a relative path. +- ``.py`` : The python file you wrote. Needs to be at the same level as ``manimlib/``, otherwise you need to use an absolute path or a relative path. - ```` : The scene you want to render here. If it is not written or written incorrectly, it will list all for you to choose. And if there is only one ``Scene`` in the file, this class will be rendered directly. - ```` : CLI flags. @@ -48,6 +50,7 @@ flag abbr function ``--write_all`` ``-a`` Write all the scenes from a file ``--open`` ``-o`` Automatically open the saved file once its done ``--finder`` Show the output file in finder +``--config`` Guide for automatic configuration ``--file_name FILE_NAME`` Name for the movie or image file ``--start_at_animation_number START_AT_ANIMATION_NUMBER`` ``-n`` Start rendering not from the first animation, but from another, specified by its index. If you passin two comma separated values, e.g. "3,6", it will end the rendering at the second value. ``--resolution RESOLUTION`` ``-r`` Resolution, passed as "WxH", e.g. "1920x1080" @@ -57,15 +60,15 @@ flag abbr function ``--video_dir VIDEO_DIR`` directory to write video ========================================================== ====== ================================================================================================================================================================================================= -custom_default +custom_config -------------- In order to perform more configuration (about directories, etc.) and permanently change the default value (you don't have to add flags to the command every time), -you can modify ``custom_default.yml``. The meaning of each option is in -page :doc:`../documentation/custom_default`. +you can modify ``custom_config.yml``. The meaning of each option is in +page :doc:`../documentation/custom_config`. -You can also use different ``custom_default.yml`` for different directories, such as +You can also use different ``custom_config.yml`` for different directories, such as following the directory structure: .. code-block:: text @@ -74,13 +77,13 @@ following the directory structure: ├── manimlib/ │ ├── animation/ │ ├── ... + │ ├── default_config.yml │ └── window.py ├── project/ │ ├── code.py - │ └── custom_default.yml - ├── custom_default.yml - └── manim.py + │ └── custom_config.yml + └── custom_config.yml -When you enter the ``project/`` folder and run ``python ../manim.py code.py ``, -it will overwrite ``manim/custom_default.yml`` with ``custom_default.yml`` +When you enter the ``project/`` folder and run ``manimgl code.py ``, +it will overwrite ``manim/custom_config.yml`` with ``custom_config.yml`` in the ``project`` folder. \ No newline at end of file diff --git a/docs/source/getting_started/example_scenes.rst b/docs/source/getting_started/example_scenes.rst index efc6c16c..5f9d1f33 100644 --- a/docs/source/getting_started/example_scenes.rst +++ b/docs/source/getting_started/example_scenes.rst @@ -11,7 +11,7 @@ SquareToCircle .. manim-example:: SquareToCircle :media: ../_static/example_scenes/SquareToCircle.mp4 - from manimlib.imports import * + from manimlib import * class SquareToCircle(Scene): def construct(self): diff --git a/docs/source/getting_started/installation.rst b/docs/source/getting_started/installation.rst index 06253786..62f95885 100644 --- a/docs/source/getting_started/installation.rst +++ b/docs/source/getting_started/installation.rst @@ -55,15 +55,6 @@ For Anaconda git clone https://github.com/3b1b/manim.git cd manim - conda env create -f environment.yml - -Using virtualenv and virtualenvwrapper --------------------------------------- - -After installing ``virtualenv`` and ``virtualenvwrapper`` - -.. code-block:: sh - - git clone https://github.com/3b1b/manim.git - mkvirtualenv -a manim -r requirements.txt manim - python -m manim example_scenes.py OpeningManimExample \ No newline at end of file + conda create -n manim python=3.8 + conda activate manim + pip install -e . \ No newline at end of file diff --git a/docs/source/getting_started/quickstart.rst b/docs/source/getting_started/quickstart.rst index 4299b24b..09313889 100644 --- a/docs/source/getting_started/quickstart.rst +++ b/docs/source/getting_started/quickstart.rst @@ -14,9 +14,9 @@ directory structure: ├── manimlib/ │ ├── animation/ │ ├── ... + │ ├── default_config.yml │ └── window.py - ├── custom_default.yml - ├── manim.py + ├── custom_config.yml └── start.py And paste the following code (I will explain the function of each line in detail later): @@ -24,7 +24,7 @@ And paste the following code (I will explain the function of each line in detail .. code-block:: python :linenos: - from manimlib.imports import * + from manimlib import * class SquareToCircle(Scene): def construct(self): @@ -38,7 +38,7 @@ And run this command: .. code-block:: sh - python manim.py start.py SquareToCircle + manimgl start.py SquareToCircle A window will pop up on the screen. And then you can : @@ -53,7 +53,7 @@ Run this command again: .. code-block:: sh - python manim.py start.py SquareToCircle -os + manimgl start.py SquareToCircle -os At this time, no window will pop up. When the program is finished, this rendered image will be automatically opened (saved in the subdirectory ``images/`` of the same @@ -71,7 +71,7 @@ Next, let's take a detailed look at what each row does. .. code-block:: python - from manimlib.imports import * + from manimlib import * This will import all the classes that may be used when using manim. @@ -129,7 +129,7 @@ Let's change some codes and add some animations to make videos instead of just p .. code-block:: python :linenos: - from manimlib.imports import * + from manimlib import * class SquareToCircle(Scene): def construct(self): @@ -147,14 +147,14 @@ Run this command this time: .. code-block:: sh - python manim.py start.py SquareToCircle + manimgl start.py SquareToCircle The pop-up window will play animations of drawing a square and transforming it into a circle. If you want to save this video, run: .. code-block:: sh - python manim.py start.py SquareToCircle -ow + manimgl start.py SquareToCircle -ow This time there will be no pop-up window, but the video file (saved in the subdirectory ``videos/`` of the same level directory of ``start.py`` by default) will be automatically @@ -209,7 +209,7 @@ at the end of the code to enable interaction: self.embed() -Then run ``python manim.py start.py SquareToCircle``. +Then run ``manimgl start.py SquareToCircle``. After the previous animation is executed, the ipython terminal will be opened on the command line. After that, you can continue to write code in it, and the statement @@ -245,7 +245,7 @@ empty scene containing only ``self.embed()``, you can directly run the following .. code-block:: sh - python manim.py + manimgl You succeeded! -------------- diff --git a/docs/source/getting_started/structure.rst b/docs/source/getting_started/structure.rst index 5bb92d49..f45165ff 100644 --- a/docs/source/getting_started/structure.rst +++ b/docs/source/getting_started/structure.rst @@ -12,107 +12,105 @@ Below is the directory structure of manim: .. code-block:: text - ├── manim.py # Manim command entry - ├── custom_default.yml # Default configuration - └── manimlib/ # manim library - ├── __init__.py # run from here - ├── config.py # Process CLI flags - ├── constants.py # Defined some constants - ├── extract_scene.py # Extract and run the scene - ├── imports.py # Import all required files in manimlib - ├── shader_wrapper.py # Shaders' Wrapper for convenient control - ├── window.py # Playback window - ├── tex_templates/ # Templates preset for LaTeX - │ ├── tex_templates.tex # Tex template (will be compiled with latex, default) - │ └── ctex_templates.tex # Tex template that support Chinese (will be compiled with xelatex) - ├── camera/ - │ └── camera.py # Including Camera and CameraFrame - ├── scene/ - │ ├── scene_file_writer.py # Used to write scene to video file - │ ├── scene.py # The basic Scene class - │ ├── three_d_scene.py # Three-dimensional scene - │ ├── graph_scene.py # GraphScene (with coordinate axis) - │ ├── reconfigurable_scene.py - │ ├── sample_space_scene.py # Probability related sample space scene - │ └── vector_space_scene.py # Vector field scene - ├── animation/ - │ ├── animation.py # The basic class of animation - │ ├── composition.py # Animation group - │ ├── creation.py # Animation related to Create - │ ├── fading.py # Fade related animation - │ ├── growing.py # Animation related to Grow - │ ├── indication.py # Some animations for emphasis - │ ├── movement.py # Animation related to movement - │ ├── numbers.py # Realize changes to DecimalNumber - │ ├── rotation.py # Animation related to rotation - │ ├── specialized.py # Some uncommon animations for special projects - │ ├── transform_matching_parts.py # Transform which can automatically match parts - │ ├── transform.py # Some Transforms - │ └── update.py # Realize update from function - ├── mobject/ - │ ├── mobject.py # The basic class of all math object - │ ├── types/ # 4 types of mobject - │ │ ├── dot_cloud.py # Dot cloud (an subclass of PMobject) - │ │ ├── image_mobject.py # Insert pictures - │ │ ├── point_cloud_mobject.py # PMobject (mobject composed of points) - │ │ ├── surface.py # ParametricSurface - │ │ └── vectorized_mobject.py # VMobject (vectorized mobject) - │ ├── svg/ # mobject related to svg - │ │ ├── svg_mobject.py # SVGMobject - │ │ ├── brace.py # Brace - │ │ ├── drawings.py # Some special mobject of svg image - │ │ ├── tex_mobject.py # Tex and TexText implemented by LaTeX - │ │ └── text_mobject.py # Text implemented by cairo - │ ├── changing.py # Dynamically changing mobject - │ ├── coordinate_systems.py # coordinate system - │ ├── frame.py # mobject related to frame - │ ├── functions.py # ParametricFunction - │ ├── geometry.py # geometry mobjects - │ ├── matrix.py # matrix - │ ├── mobject_update_utils.py # some defined updater - │ ├── number_line.py # Number line - │ ├── numbers.py # Numbers that can be changed - │ ├── probability.py # mobject related to probability - │ ├── shape_matchers.py # mobject adapted to the size of other objects - │ ├── three_dimensions.py # Three-dimensional objects - │ ├── value_tracker.py # ValueTracker which storage number - │ └── vector_field.py # VectorField - ├── once_useful_constructs/ # 3b1b's Common scenes written for some videos - │ └── ... - ├── shaders/ # GLSL scripts for rendering - │ ├── simple_vert.glsl # a simple glsl script for position - │ ├── insert/ # glsl scripts to be inserted in other glsl scripts - │ │ ├── NOTE.md # explain how to insert glsl scripts - │ │ └── ... # useful scripts - │ ├── image/ # glsl for images - │ │ └── ... # containing shaders for vertex and fragment - │ ├── quadratic_bezier_fill/ # glsl for the fill of quadratic bezier curve - │ │ └── ... # containing shaders for vertex, fragment and geometry - │ ├── quadratic_bezier_stroke/ # glsl for the stroke of quadratic bezier curve - │ │ └── ... # containing shaders for vertex, fragment and geometry - │ ├── surface/ # glsl for surfaces - │ │ └── ... # containing shaders for vertex and fragment - │ ├── textured_surface/ # glsl for textured_surface - │ │ └── ... # containing shaders for vertex and fragment - │ └── true_dot/ # glsl for a dot - │ └── ... # containing shaders for vertex, fragment and geometry - └── utils/ # Some useful utility functions - ├── bezier.py # For bezier curve - ├── color.py # For color - ├── config_ops.py # Process CONFIG - ├── customization.py # Read from custom_default.yml - ├── debug.py # Utilities for debugging in program - ├── family_ops.py # Process family members - ├── file_ops.py # Process files and directories - ├── images.py # Read image - ├── iterables.py # Functions related to list/dictionary processing - ├── paths.py # Curve path - ├── rate_functions.py # Some defined rate_functions - ├── simple_functions.py # Some commonly used functions - ├── sounds.py # Process sounds - ├── space_ops.py # Space coordinate calculation - ├── strings.py # Process strings - └── tex_file_writing.py # Use LaTeX to write strings as svg + manimlib/ # manim library + ├── __init__.py + ├── __main__.py + ├── default_config.yml # Default configuration file + ├── config.py # Process CLI flags + ├── constants.py # Defined some constants + ├── extract_scene.py # Extract and run the scene + ├── shader_wrapper.py # Shaders' Wrapper for convenient control + ├── window.py # Playback window + ├── tex_templates/ # Templates preset for LaTeX + │ ├── tex_templates.tex # Tex template (will be compiled with latex, default) + │ └── ctex_templates.tex # Tex template that support Chinese (will be compiled with xelatex) + ├── camera/ + │ └── camera.py # Including Camera and CameraFrame + ├── scene/ + │ ├── scene_file_writer.py # Used to write scene to video file + │ ├── scene.py # The basic Scene class + │ ├── three_d_scene.py # Three-dimensional scene + │ ├── sample_space_scene.py # Probability related sample space scene + │ └── vector_space_scene.py # Vector field scene + ├── animation/ + │ ├── animation.py # The basic class of animation + │ ├── composition.py # Animation group + │ ├── creation.py # Animation related to Create + │ ├── fading.py # Fade related animation + │ ├── growing.py # Animation related to Grow + │ ├── indication.py # Some animations for emphasis + │ ├── movement.py # Animation related to movement + │ ├── numbers.py # Realize changes to DecimalNumber + │ ├── rotation.py # Animation related to rotation + │ ├── specialized.py # Some uncommon animations for special projects + │ ├── transform_matching_parts.py # Transform which can automatically match parts + │ ├── transform.py # Some Transforms + │ └── update.py # Realize update from function + ├── mobject/ + │ ├── mobject.py # The basic class of all math object + │ ├── types/ # 4 types of mobject + │ │ ├── dot_cloud.py # Dot cloud (an subclass of PMobject) + │ │ ├── image_mobject.py # Insert pictures + │ │ ├── point_cloud_mobject.py # PMobject (mobject composed of points) + │ │ ├── surface.py # ParametricSurface + │ │ └── vectorized_mobject.py # VMobject (vectorized mobject) + │ ├── svg/ # mobject related to svg + │ │ ├── svg_mobject.py # SVGMobject + │ │ ├── brace.py # Brace + │ │ ├── drawings.py # Some special mobject of svg image + │ │ ├── tex_mobject.py # Tex and TexText implemented by LaTeX + │ │ └── text_mobject.py # Text implemented by cairo + │ ├── changing.py # Dynamically changing mobject + │ ├── coordinate_systems.py # coordinate system + │ ├── frame.py # mobject related to frame + │ ├── functions.py # ParametricFunction + │ ├── geometry.py # geometry mobjects + │ ├── matrix.py # matrix + │ ├── mobject_update_utils.py # some defined updater + │ ├── number_line.py # Number line + │ ├── numbers.py # Numbers that can be changed + │ ├── probability.py # mobject related to probability + │ ├── shape_matchers.py # mobject adapted to the size of other objects + │ ├── three_dimensions.py # Three-dimensional objects + │ ├── value_tracker.py # ValueTracker which storage number + │ └── vector_field.py # VectorField + ├── once_useful_constructs/ # 3b1b's Common scenes written for some videos + │ └── ... + ├── shaders/ # GLSL scripts for rendering + │ ├── simple_vert.glsl # a simple glsl script for position + │ ├── insert/ # glsl scripts to be inserted in other glsl scripts + │ │ ├── NOTE.md # explain how to insert glsl scripts + │ │ └── ... # useful scripts + │ ├── image/ # glsl for images + │ │ └── ... # containing shaders for vertex and fragment + │ ├── quadratic_bezier_fill/ # glsl for the fill of quadratic bezier curve + │ │ └── ... # containing shaders for vertex, fragment and geometry + │ ├── quadratic_bezier_stroke/ # glsl for the stroke of quadratic bezier curve + │ │ └── ... # containing shaders for vertex, fragment and geometry + │ ├── surface/ # glsl for surfaces + │ │ └── ... # containing shaders for vertex and fragment + │ ├── textured_surface/ # glsl for textured_surface + │ │ └── ... # containing shaders for vertex and fragment + │ └── true_dot/ # glsl for a dot + │ └── ... # containing shaders for vertex, fragment and geometry + └── utils/ # Some useful utility functions + ├── bezier.py # For bezier curve + ├── color.py # For color + ├── config_ops.py # Process CONFIG + ├── customization.py # Read from custom_config.yml + ├── debug.py # Utilities for debugging in program + ├── family_ops.py # Process family members + ├── file_ops.py # Process files and directories + ├── images.py # Read image + ├── init_config.py # Configuration guide + ├── iterables.py # Functions related to list/dictionary processing + ├── paths.py # Curve path + ├── rate_functions.py # Some defined rate_functions + ├── simple_functions.py # Some commonly used functions + ├── sounds.py # Process sounds + ├── space_ops.py # Space coordinate calculation + ├── strings.py # Process strings + └── tex_file_writing.py # Use LaTeX to write strings as svg Inheritance structure of manim's classes ---------------------------------------- diff --git a/docs/source/index.rst b/docs/source/index.rst index 84df7151..14cc0157 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,7 +24,7 @@ And here is a Chinese version of this documentation: https://manim.ml/shaders :caption: Documentation documentation/constants - documentation/custom_default + documentation/custom_config .. toctree:: :maxdepth: 2 From 944128d9bfd85e1898fbe811455fc543f9154e85 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 12:16:57 +0800 Subject: [PATCH 12/15] adjust the order of arguments in config --- manimlib/config.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/manimlib/config.py b/manimlib/config.py index 433ea74f..158661e7 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -95,15 +95,15 @@ def parse_cli(): action="store_true", help="Show the output file in finder", ) - parser.add_argument( - "--file_name", - help="Name for the movie or image file", - ) parser.add_argument( "--config", action="store_true", help="Guide for automatic configuration", ) + parser.add_argument( + "--file_name", + help="Name for the movie or image file", + ) parser.add_argument( "-n", "--start_at_animation_number", help="Start rendering not from the first animation, but" From 6331f76c12c68dbdef0f185713e34c961aeddf94 Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 12:22:34 +0800 Subject: [PATCH 13/15] import numpy in example_scenes --- example_scenes.py | 1 + 1 file changed, 1 insertion(+) diff --git a/example_scenes.py b/example_scenes.py index 4dddbf4c..feff9bd7 100644 --- a/example_scenes.py +++ b/example_scenes.py @@ -1,4 +1,5 @@ from manimlib import * +import numpy as np # To watch one of these scenes, run the following: # python -m manim example_scenes.py SquareToCircle From 7c683c8992b5829b1de42320f51bcff2e9bce2ea Mon Sep 17 00:00:00 2001 From: Tony031218 <975062472@qq.com> Date: Mon, 8 Feb 2021 12:25:26 +0800 Subject: [PATCH 14/15] updte default universal_import_line --- manimlib/default_config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manimlib/default_config.yml b/manimlib/default_config.yml index d34236ae..45b3b77b 100644 --- a/manimlib/default_config.yml +++ b/manimlib/default_config.yml @@ -25,7 +25,7 @@ tex: # executable: "xelatex -no-pdf" # template_file: "ctex_template.tex" # intermediate_filetype: "xdv" -universal_import_line: "from manimlib.imports import *" +universal_import_line: "from manimlib import *" style: font: "Consolas" background_color: "#333333" From 5df4e68f1b1c6d4f9bd9d66e931b7675bc34aabc Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Thu, 11 Feb 2021 10:15:28 -0800 Subject: [PATCH 15/15] Remove from manimlib.mobject.interactive import * --- manimlib/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/manimlib/__init__.py b/manimlib/__init__.py index b440aaa3..bec85a17 100644 --- a/manimlib/__init__.py +++ b/manimlib/__init__.py @@ -27,7 +27,6 @@ from manimlib.mobject.number_line import * from manimlib.mobject.numbers import * from manimlib.mobject.probability import * from manimlib.mobject.shape_matchers import * -from manimlib.mobject.interactive import * from manimlib.mobject.svg.brace import * from manimlib.mobject.svg.drawings import * from manimlib.mobject.svg.svg_mobject import *