Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix not being able to set some CLI flags in the configuration file (#1763)

Mohammad Al-Fetyani13369e3ad5de
diff --git a/docs/source/tutorials/configuration.rst b/docs/source/tutorials/configuration.rst
index 3382e39ca..11fadd86b 100644
--- a/docs/source/tutorials/configuration.rst
+++ b/docs/source/tutorials/configuration.rst
@@ -347,7 +347,7 @@ A list of all config options
'from_animation_number', `fullscreen`, 'images_dir', 'input_file', 'left_side',
'log_dir', 'log_to_file', 'max_files_cached', 'media_dir', 'media_width',
'movie_file_extension', 'notify_outdated_version', 'output_file', 'partial_movie_dir',
- 'pixel_height', 'pixel_width', 'plugins', 'png_mode', 'preview',
+ 'pixel_height', 'pixel_width', 'plugins', 'preview',
'progress_bar', 'quality', 'right_side', 'save_as_gif', 'save_last_frame',
'save_pngs', 'scene_names', 'show_in_file_browser', 'sound', 'tex_dir',
'tex_template', 'tex_template_file', 'text_dir', 'top', 'transparent',
diff --git a/manim/_config/default.cfg b/manim/_config/default.cfg
index dbf46a3ad..af3494765 100644
--- a/manim/_config/default.cfg
+++ b/manim/_config/default.cfg
@@ -120,9 +120,6 @@ use_projection_fill_shaders = False
# --use_projection_stroke_shaders
use_projection_stroke_shaders = False
-# If the -t (--transparent) flag is used, these will be replaced with the
-# values specified in the [TRANSPARENT] section later in this file.
-png_mode = RGB
movie_file_extension = .mp4
# These now override the --quality option.
diff --git a/manim/_config/utils.py b/manim/_config/utils.py
index cf13e53a7..afafa243e 100644
--- a/manim/_config/utils.py
+++ b/manim/_config/utils.py
@@ -269,7 +269,6 @@ class ManimConfig(MutableMapping):
"pixel_height",
"pixel_width",
"plugins",
- "png_mode",
"preview",
"progress_bar",
"save_as_gif",
@@ -557,7 +556,6 @@ class ManimConfig(MutableMapping):
"partial_movie_dir",
"input_file",
"output_file",
- "png_mode",
"movie_file_extension",
"background_color",
"renderer",
@@ -747,7 +745,8 @@ class ManimConfig(MutableMapping):
self["write_to_movie"] = False
# Handle --gui_location flag.
- self.gui_location = args.gui_location
+ if getattr(args, "gui_location") is not None:
+ self.gui_location = args.gui_location
return self
@@ -1030,12 +1029,6 @@ class ManimConfig(MutableMapping):
doc="Whether a warning is raised if there are too much submobjects to hash.",
)
- png_mode = property(
- lambda self: self._d["png_mode"],
- lambda self, val: self._set_from_list("png_mode", val, ["RGB", "RGBA"]),
- doc="Either RGA (no transparency) or RGBA (with transparency) (no flag).",
- )
-
movie_file_extension = property(
lambda self: self._d["movie_file_extension"],
lambda self, val: self._set_from_list(
@@ -1085,12 +1078,7 @@ class ManimConfig(MutableMapping):
@transparent.setter
def transparent(self, val: bool) -> None:
- if val:
- self.png_mode = "RGBA"
- self.background_opacity = 0.0
- else:
- self.png_mode = "RGB"
- self.background_opacity = 1.0
+ self._d["background_opacity"] = float(not val)
self.resolve_movie_file_extension(val)
@property
diff --git a/manim/cli/render/ease_of_access_options.py b/manim/cli/render/ease_of_access_options.py
index 858b4e011..bd3b858ac 100644
--- a/manim/cli/render/ease_of_access_options.py
+++ b/manim/cli/render/ease_of_access_options.py
@@ -5,8 +5,8 @@ ease_of_access_options = option_group(
"Ease of access options",
option(
"--progress_bar",
- default="display",
- show_default=True,
+ default=None,
+ show_default=False,
type=click.Choice(
["display", "leave", "none"],
case_sensitive=False,
@@ -20,12 +20,19 @@ ease_of_access_options = option_group(
help="Preview the Scene's animation. OpenGL does a live preview in a "
"popup window. Cairo opens the rendered video file in the system "
"default media player.",
+ default=None,
),
option(
"-f",
"--show_in_file_browser",
is_flag=True,
help="Show the output file in the file browser.",
+ default=None,
+ ),
+ option(
+ "--jupyter",
+ is_flag=True,
+ help="Using jupyter notebook magic.",
+ default=None,
),
- option("--jupyter", is_flag=True, help="Using jupyter notebook magic."),
)
diff --git a/manim/cli/render/global_options.py b/manim/cli/render/global_options.py
index 1d6190f03..6f477c975 100644
--- a/manim/cli/render/global_options.py
+++ b/manim/cli/render/global_options.py
@@ -22,20 +22,28 @@ global_options = option_group(
"-c",
"--config_file",
help="Specify the configuration file to use for render settings.",
+ default=None,
),
option(
"--custom_folders",
is_flag=True,
+ default=None,
help="Use the folders defined in the [custom_folders] section of the "
"config file to define the output folder structure.",
),
option(
"--disable_caching",
is_flag=True,
+ default=None,
help="Disable the use of the cache (still generates cache files).",
),
- option("--flush_cache", is_flag=True, help="Remove cached partial movie files."),
- option("--tex_template", help="Specify a custom TeX template file."),
+ option(
+ "--flush_cache",
+ is_flag=True,
+ help="Remove cached partial movie files.",
+ default=None,
+ ),
+ option("--tex_template", help="Specify a custom TeX template file.", default=None),
option(
"-v",
"--verbosity",
@@ -44,6 +52,7 @@ global_options = option_group(
case_sensitive=False,
),
help="Verbosity of CLI output. Changes ffmpeg log level unless 5+.",
+ default=None,
),
option(
"--notify_outdated_version/--silent",
@@ -55,10 +64,11 @@ global_options = option_group(
"--enable_gui",
is_flag=True,
help="Enable GUI interaction.",
+ default=None,
),
option(
"--gui_location",
- default="0,0",
+ default=None,
callback=validate_gui_location,
help="Starting location for the GUI.",
),
@@ -66,5 +76,6 @@ global_options = option_group(
"--fullscreen",
is_flag=True,
help="Expand the window to its maximum possible size.",
+ default=None,
),
)
diff --git a/manim/cli/render/output_options.py b/manim/cli/render/output_options.py
index 6eb6484d8..a48aaed21 100644
--- a/manim/cli/render/output_options.py
+++ b/manim/cli/render/output_options.py
@@ -7,6 +7,7 @@ output_options = option_group(
"-o",
"--output_file",
type=str,
+ default=None,
help="Specify the filename(s) of the rendered scene(s).",
),
option(
@@ -18,12 +19,16 @@ output_options = option_group(
option(
"--media_dir",
type=click.Path(),
+ default=None,
help="Path to store rendered videos and latex.",
),
- option("--log_dir", type=click.Path(), help="Path to store render logs."),
+ option(
+ "--log_dir", type=click.Path(), help="Path to store render logs.", default=None
+ ),
option(
"--log_to_file",
is_flag=True,
+ default=None,
help="Log terminal output to file.",
),
)
diff --git a/manim/cli/render/render_options.py b/manim/cli/render/render_options.py
index f4a8560f7..13ecf9632 100644
--- a/manim/cli/render/render_options.py
+++ b/manim/cli/render/render_options.py
@@ -40,22 +40,25 @@ render_options = option_group(
callback=validate_scene_range,
help="Start rendering from n_0 until n_1. If n_1 is left unspecified, "
"renders all scenes after n_0.",
+ default=None,
),
option(
"-a",
"--write_all",
is_flag=True,
help="Render all scenes in the input file.",
+ default=None,
),
option(
"--format",
type=click.Choice(["png", "gif", "mp4", "webm", "mov"], case_sensitive=False),
+ default=None,
),
- option("-s", "--save_last_frame", is_flag=True),
+ option("-s", "--save_last_frame", is_flag=True, default=None),
option(
"-q",
"--quality",
- default="h",
+ default=None,
type=click.Choice(["l", "m", "h", "p", "k"], case_sensitive=False),
help="""
Render quality at the follow resolution framerates, respectively:
@@ -70,6 +73,7 @@ render_options = option_group(
"-r",
"--resolution",
callback=validate_resolution,
+ default=None,
help="Resolution in (W,H) for when 16:9 aspect ratio isn't possible.",
),
option(
@@ -77,22 +81,26 @@ render_options = option_group(
"--frame_rate",
"frame_rate",
type=float,
+ default=None,
help="Render at this frame rate.",
),
option(
"--renderer",
type=click.Choice(["cairo", "opengl", "webgl"], case_sensitive=False),
help="Select a renderer for your Scene.",
+ default=None,
),
option(
"--use_opengl_renderer",
is_flag=True,
help="Render scenes using OpenGL (Deprecated).",
+ default=None,
),
option(
"--use_webgl_renderer",
is_flag=True,
help="Render scenes using the WebGL frontend (Deprecated).",
+ default=None,
),
option(
"--webgl_renderer_path",
@@ -122,16 +130,21 @@ render_options = option_group(
help="Save last frame as png (Deprecated).",
),
option(
- "-t", "--transparent", is_flag=True, help="Render scenes with alpha channel."
+ "-t",
+ "--transparent",
+ is_flag=True,
+ help="Render scenes with alpha channel.",
),
option(
"--use_projection_fill_shaders",
is_flag=True,
help="Use shaders for OpenGLVMobject fill which are compatible with transformation matrices.",
+ default=None,
),
option(
"--use_projection_stroke_shaders",
is_flag=True,
help="Use shaders for OpenGLVMobject stroke which are compatible with transformation matrices.",
+ default=None,
),
)
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index d79534fd6..19e659ff2 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -41,8 +41,6 @@ class SceneFileWriter(object):
Some useful attributes are:
"write_to_movie" (bool=False)
Whether or not to write the animations into a video file.
- "png_mode" (str="RGBA")
- The PIL image mode to use when outputting PNGs
"movie_file_extension" (str=".mp4")
The file-type extension of the outputted video.
"partial_movie_files"