A community-maintained Python framework for creating mathematical animations.
Fix -t flag and add a test to it. Also add test for -c flag.
leotrs11a020d024e6
diff --git a/manim/camera/camera.py b/manim/camera/camera.pyindex f9811705a..84bbdc50e 100644--- a/manim/camera/camera.py+++ b/manim/camera/camera.py@@ -53,7 +53,6 @@ class Camera(object):# Note: frame height and width will be resized to match# the pixel aspect ratio"frame_center": ORIGIN,- "background_opacity": 1,# Points in vectorized mobjects with norm greater# than this value will be rescaled."image_mode": "RGBA",@@ -91,6 +90,7 @@ class Camera(object):"frame_width","frame_rate","background_color",+ "background_opacity",]:setattr(self, attr, kwargs.get(attr, config[attr]))diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.pyindex a33202e9f..b177dd2c9 100644--- a/manim/scene/scene_file_writer.py+++ b/manim/scene/scene_file_writer.py@@ -432,22 +432,10 @@ class SceneFileWriter(object):"-loglevel",config["ffmpeg_loglevel"].lower(),]- # TODO, the test for a transparent background should not be based on- # the file extension.- if config["movie_file_extension"] == ".mov":- # This is if the background of the exported- # video should be transparent.- command += [- "-vcodec",- "qtrle",- ]+ if config["transparent"]:+ command += ["-vcodec", "qtrle"]else:- command += [- "-vcodec",- "libx264",- "-pix_fmt",- "yuv420p",- ]+ command += ["-vcodec", "libx264", "-pix_fmt", "yuv420p"]command += [temp_file_path]self.writing_process = subprocess.Popen(command, stdin=subprocess.PIPE)diff --git a/tests/test_config.py b/tests/test_config.pyindex bb906578d..a7c8437a3 100644--- a/tests/test_config.py+++ b/tests/test_config.py@@ -1,6 +1,6 @@import pytestimport numpy as np-from manim import config, tempconfig+from manim import config, tempconfig, Scene, Square, WHITEdef test_tempconfig():@@ -24,3 +24,37 @@ def test_tempconfig():assert np.allclose(config[k], v)else:assert config[k] == v+++class MyScene(Scene):+ def construct(self):+ self.add(Square())+ self.wait(1)+++def test_transparent():+ """Test the 'transparent' config option."""+ orig_verbosity = config["verbosity"]+ config["verbosity"] = "ERROR"++ scene = MyScene()+ scene.render()+ frame = scene.renderer.get_frame()+ assert np.allclose(frame[0, 0], [0, 0, 0, 255])++ with tempconfig({"transparent": True}):+ scene = MyScene()+ scene.render()+ frame = scene.renderer.get_frame()+ assert np.allclose(frame[0, 0], [0, 0, 0, 0])++ config["verbosity"] = orig_verbosity+++def test_background_color():+ """Test the 'background_color' config option."""+ with tempconfig({"background_color": WHITE, "verbosity": "ERROR"}):+ scene = MyScene()+ scene.render()+ frame = scene.renderer.get_frame()+ assert np.allclose(frame[0, 0], [255, 255, 255, 255])