A community-maintained Python framework for creating mathematical animations.
New Feature: Added media_width option to the config to change the default width of gif+video output in Jupyter notebooks (#1074)
Darylgolden1d9fdaf6296c
diff --git a/docs/source/tutorials/configuration.rst b/docs/source/tutorials/configuration.rstindex 8b5241239..cd67da0e6 100644--- a/docs/source/tutorials/configuration.rst+++ b/docs/source/tutorials/configuration.rst@@ -352,7 +352,7 @@ A list of all config options'frame_height', 'frame_rate', 'frame_size', 'frame_width', 'frame_x_radius','frame_y_radius', 'from_animation_number', 'images_dir', 'input_file','leave_progress_bars', 'left_side', 'log_dir', 'log_to_file',- 'max_files_cached', 'media_dir', 'movie_file_extension', 'output_file',+ 'max_files_cached', 'media_dir', 'media_width', 'movie_file_extension', 'output_file','partial_movie_dir', 'pixel_height', 'pixel_width', 'plugins', 'png_mode','preview', 'progress_bar', 'quality', 'right_side', 'save_as_gif', 'save_last_frame','save_pngs', 'scene_names', 'show_in_file_browser', 'sound', 'tex_dir',diff --git a/manim/_config/default.cfg b/manim/_config/default.cfgindex 5135d5690..43bffb3e3 100644--- a/manim/_config/default.cfg+++ b/manim/_config/default.cfg@@ -156,3 +156,6 @@ repr_number = green# Uncomment the following line to manually set the loglevel for ffmpeg. See# ffmpeg manpage for accepted valuesloglevel = ERROR++[jupyter]+media_width = 25vwdiff --git a/manim/_config/utils.py b/manim/_config/utils.pyindex c11c8bf41..70e497659 100644--- a/manim/_config/utils.py+++ b/manim/_config/utils.py@@ -263,6 +263,7 @@ class ManimConfig(MutableMapping):"from_animation_number","images_dir","input_file",+ "media_width","webgl_renderer_path","leave_progress_bars","log_dir",@@ -576,6 +577,10 @@ class ManimConfig(MutableMapping):if val:setattr(self, "ffmpeg_loglevel", val)+ val = parser["jupyter"].get("media_width")+ if val:+ setattr(self, "media_width", val)+return selfdef digest_args(self, args: argparse.Namespace) -> "ManimConfig":@@ -854,6 +859,12 @@ class ManimConfig(MutableMapping):doc="Verbosity level of ffmpeg (no flag).",)+ media_width = property(+ lambda self: self._d["media_width"],+ lambda self, val: self._d.__setitem__("media_width", val),+ doc="Media width in Jupyter notebook",+ )+pixel_width = property(lambda self: self._d["pixel_width"],lambda self, val: self._set_pos_number("pixel_width", val, False),diff --git a/manim/utils/ipython_magic.py b/manim/utils/ipython_magic.pyindex 4fd9cc745..433baba46 100644--- a/manim/utils/ipython_magic.py+++ b/manim/utils/ipython_magic.py@@ -103,7 +103,7 @@ else:display(Video(tmpfile,- html_attributes='controls autoplay loop style="max-width: 100%;"',+ html_attributes=f'controls autoplay loop style="max-width: {config["media_width"]};"',embed=video_embed,))