Skip to content

Commit 13369e3

Browse files
authoredJul 9, 2021
Fix not being able to set some CLI flags in the configuration file (ManimCommunity#1763)
* Default options to None * Fix tests. transparent cannot be set in the config file * Remove unused "png_mode" flag * update
1 parent 5eb0b1d commit 13369e3

File tree

8 files changed

+50
-31
lines changed

8 files changed

+50
-31
lines changed
 

‎docs/source/tutorials/configuration.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ A list of all config options
347347
'from_animation_number', `fullscreen`, 'images_dir', 'input_file', 'left_side',
348348
'log_dir', 'log_to_file', 'max_files_cached', 'media_dir', 'media_width',
349349
'movie_file_extension', 'notify_outdated_version', 'output_file', 'partial_movie_dir',
350-
'pixel_height', 'pixel_width', 'plugins', 'png_mode', 'preview',
350+
'pixel_height', 'pixel_width', 'plugins', 'preview',
351351
'progress_bar', 'quality', 'right_side', 'save_as_gif', 'save_last_frame',
352352
'save_pngs', 'scene_names', 'show_in_file_browser', 'sound', 'tex_dir',
353353
'tex_template', 'tex_template_file', 'text_dir', 'top', 'transparent',

‎manim/_config/default.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ use_projection_fill_shaders = False
120120
# --use_projection_stroke_shaders
121121
use_projection_stroke_shaders = False
122122

123-
# If the -t (--transparent) flag is used, these will be replaced with the
124-
# values specified in the [TRANSPARENT] section later in this file.
125-
png_mode = RGB
126123
movie_file_extension = .mp4
127124

128125
# These now override the --quality option.

‎manim/_config/utils.py

+3-15
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ class MyScene(Scene):
269269
"pixel_height",
270270
"pixel_width",
271271
"plugins",
272-
"png_mode",
273272
"preview",
274273
"progress_bar",
275274
"save_as_gif",
@@ -557,7 +556,6 @@ def digest_parser(self, parser: configparser.ConfigParser) -> "ManimConfig":
557556
"partial_movie_dir",
558557
"input_file",
559558
"output_file",
560-
"png_mode",
561559
"movie_file_extension",
562560
"background_color",
563561
"renderer",
@@ -747,7 +745,8 @@ def digest_args(self, args: argparse.Namespace) -> "ManimConfig":
747745
self["write_to_movie"] = False
748746

749747
# Handle --gui_location flag.
750-
self.gui_location = args.gui_location
748+
if getattr(args, "gui_location") is not None:
749+
self.gui_location = args.gui_location
751750

752751
return self
753752

@@ -1030,12 +1029,6 @@ def format(self, val: str) -> None:
10301029
doc="Whether a warning is raised if there are too much submobjects to hash.",
10311030
)
10321031

1033-
png_mode = property(
1034-
lambda self: self._d["png_mode"],
1035-
lambda self, val: self._set_from_list("png_mode", val, ["RGB", "RGBA"]),
1036-
doc="Either RGA (no transparency) or RGBA (with transparency) (no flag).",
1037-
)
1038-
10391032
movie_file_extension = property(
10401033
lambda self: self._d["movie_file_extension"],
10411034
lambda self, val: self._set_from_list(
@@ -1085,12 +1078,7 @@ def transparent(self):
10851078

10861079
@transparent.setter
10871080
def transparent(self, val: bool) -> None:
1088-
if val:
1089-
self.png_mode = "RGBA"
1090-
self.background_opacity = 0.0
1091-
else:
1092-
self.png_mode = "RGB"
1093-
self.background_opacity = 1.0
1081+
self._d["background_opacity"] = float(not val)
10941082
self.resolve_movie_file_extension(val)
10951083

10961084
@property

‎manim/cli/render/ease_of_access_options.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"Ease of access options",
66
option(
77
"--progress_bar",
8-
default="display",
9-
show_default=True,
8+
default=None,
9+
show_default=False,
1010
type=click.Choice(
1111
["display", "leave", "none"],
1212
case_sensitive=False,
@@ -20,12 +20,19 @@
2020
help="Preview the Scene's animation. OpenGL does a live preview in a "
2121
"popup window. Cairo opens the rendered video file in the system "
2222
"default media player.",
23+
default=None,
2324
),
2425
option(
2526
"-f",
2627
"--show_in_file_browser",
2728
is_flag=True,
2829
help="Show the output file in the file browser.",
30+
default=None,
31+
),
32+
option(
33+
"--jupyter",
34+
is_flag=True,
35+
help="Using jupyter notebook magic.",
36+
default=None,
2937
),
30-
option("--jupyter", is_flag=True, help="Using jupyter notebook magic."),
3138
)

‎manim/cli/render/global_options.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,28 @@ def validate_gui_location(ctx, param, value):
2222
"-c",
2323
"--config_file",
2424
help="Specify the configuration file to use for render settings.",
25+
default=None,
2526
),
2627
option(
2728
"--custom_folders",
2829
is_flag=True,
30+
default=None,
2931
help="Use the folders defined in the [custom_folders] section of the "
3032
"config file to define the output folder structure.",
3133
),
3234
option(
3335
"--disable_caching",
3436
is_flag=True,
37+
default=None,
3538
help="Disable the use of the cache (still generates cache files).",
3639
),
37-
option("--flush_cache", is_flag=True, help="Remove cached partial movie files."),
38-
option("--tex_template", help="Specify a custom TeX template file."),
40+
option(
41+
"--flush_cache",
42+
is_flag=True,
43+
help="Remove cached partial movie files.",
44+
default=None,
45+
),
46+
option("--tex_template", help="Specify a custom TeX template file.", default=None),
3947
option(
4048
"-v",
4149
"--verbosity",
@@ -44,6 +52,7 @@ def validate_gui_location(ctx, param, value):
4452
case_sensitive=False,
4553
),
4654
help="Verbosity of CLI output. Changes ffmpeg log level unless 5+.",
55+
default=None,
4756
),
4857
option(
4958
"--notify_outdated_version/--silent",
@@ -55,16 +64,18 @@ def validate_gui_location(ctx, param, value):
5564
"--enable_gui",
5665
is_flag=True,
5766
help="Enable GUI interaction.",
67+
default=None,
5868
),
5969
option(
6070
"--gui_location",
61-
default="0,0",
71+
default=None,
6272
callback=validate_gui_location,
6373
help="Starting location for the GUI.",
6474
),
6575
option(
6676
"--fullscreen",
6777
is_flag=True,
6878
help="Expand the window to its maximum possible size.",
79+
default=None,
6980
),
7081
)

‎manim/cli/render/output_options.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"-o",
88
"--output_file",
99
type=str,
10+
default=None,
1011
help="Specify the filename(s) of the rendered scene(s).",
1112
),
1213
option(
@@ -18,12 +19,16 @@
1819
option(
1920
"--media_dir",
2021
type=click.Path(),
22+
default=None,
2123
help="Path to store rendered videos and latex.",
2224
),
23-
option("--log_dir", type=click.Path(), help="Path to store render logs."),
25+
option(
26+
"--log_dir", type=click.Path(), help="Path to store render logs.", default=None
27+
),
2428
option(
2529
"--log_to_file",
2630
is_flag=True,
31+
default=None,
2732
help="Log terminal output to file.",
2833
),
2934
)

‎manim/cli/render/render_options.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,25 @@ def validate_resolution(ctx, param, value):
4040
callback=validate_scene_range,
4141
help="Start rendering from n_0 until n_1. If n_1 is left unspecified, "
4242
"renders all scenes after n_0.",
43+
default=None,
4344
),
4445
option(
4546
"-a",
4647
"--write_all",
4748
is_flag=True,
4849
help="Render all scenes in the input file.",
50+
default=None,
4951
),
5052
option(
5153
"--format",
5254
type=click.Choice(["png", "gif", "mp4", "webm", "mov"], case_sensitive=False),
55+
default=None,
5356
),
54-
option("-s", "--save_last_frame", is_flag=True),
57+
option("-s", "--save_last_frame", is_flag=True, default=None),
5558
option(
5659
"-q",
5760
"--quality",
58-
default="h",
61+
default=None,
5962
type=click.Choice(["l", "m", "h", "p", "k"], case_sensitive=False),
6063
help="""
6164
Render quality at the follow resolution framerates, respectively:
@@ -70,29 +73,34 @@ def validate_resolution(ctx, param, value):
7073
"-r",
7174
"--resolution",
7275
callback=validate_resolution,
76+
default=None,
7377
help="Resolution in (W,H) for when 16:9 aspect ratio isn't possible.",
7478
),
7579
option(
7680
"--fps",
7781
"--frame_rate",
7882
"frame_rate",
7983
type=float,
84+
default=None,
8085
help="Render at this frame rate.",
8186
),
8287
option(
8388
"--renderer",
8489
type=click.Choice(["cairo", "opengl", "webgl"], case_sensitive=False),
8590
help="Select a renderer for your Scene.",
91+
default=None,
8692
),
8793
option(
8894
"--use_opengl_renderer",
8995
is_flag=True,
9096
help="Render scenes using OpenGL (Deprecated).",
97+
default=None,
9198
),
9299
option(
93100
"--use_webgl_renderer",
94101
is_flag=True,
95102
help="Render scenes using the WebGL frontend (Deprecated).",
103+
default=None,
96104
),
97105
option(
98106
"--webgl_renderer_path",
@@ -122,16 +130,21 @@ def validate_resolution(ctx, param, value):
122130
help="Save last frame as png (Deprecated).",
123131
),
124132
option(
125-
"-t", "--transparent", is_flag=True, help="Render scenes with alpha channel."
133+
"-t",
134+
"--transparent",
135+
is_flag=True,
136+
help="Render scenes with alpha channel.",
126137
),
127138
option(
128139
"--use_projection_fill_shaders",
129140
is_flag=True,
130141
help="Use shaders for OpenGLVMobject fill which are compatible with transformation matrices.",
142+
default=None,
131143
),
132144
option(
133145
"--use_projection_stroke_shaders",
134146
is_flag=True,
135147
help="Use shaders for OpenGLVMobject stroke which are compatible with transformation matrices.",
148+
default=None,
136149
),
137150
)

‎manim/scene/scene_file_writer.py

-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ class SceneFileWriter(object):
4141
Some useful attributes are:
4242
"write_to_movie" (bool=False)
4343
Whether or not to write the animations into a video file.
44-
"png_mode" (str="RGBA")
45-
The PIL image mode to use when outputting PNGs
4644
"movie_file_extension" (str=".mp4")
4745
The file-type extension of the outputted video.
4846
"partial_movie_files"

0 commit comments

Comments
 (0)
Please sign in to comment.