Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fix opengl finish transform (#2676)

Ryan McCauley2964326040f1
diff --git a/manim/mobject/opengl/opengl_mobject.py b/manim/mobject/opengl/opengl_mobject.py
index 9aae1a576..e75b363e4 100644
--- a/manim/mobject/opengl/opengl_mobject.py
+++ b/manim/mobject/opengl/opengl_mobject.py
@@ -2729,7 +2729,6 @@ class _AnimationBuilder:
def __getattr__(self, method_name):
method = getattr(self.mobject.target, method_name)
- self.methods.append(method)
has_overridden_animation = hasattr(method, "_override_animate")
if (self.is_chaining and has_overridden_animation) or self.overridden_animation:
@@ -2747,6 +2746,7 @@ class _AnimationBuilder:
**method_kwargs,
)
else:
+ self.methods.append([method, method_args, method_kwargs])
method(*method_args, **method_kwargs)
return self
diff --git a/tests/test_scene_rendering/opengl/test_play_logic_opengl.py b/tests/test_scene_rendering/opengl/test_play_logic_opengl.py
index 4a3f634ed..5e51aee92 100644
--- a/tests/test_scene_rendering/opengl/test_play_logic_opengl.py
+++ b/tests/test_scene_rendering/opengl/test_play_logic_opengl.py
@@ -101,3 +101,19 @@ def test_t_values_save_last_frame(using_temp_opengl_config):
scene.update_to_time = Mock()
scene.render()
scene.update_to_time.assert_called_once_with(1)
+
+
+def test_animate_with_changed_custom_attribute(using_temp_opengl_config):
+ """Test that animating the change of a custom attribute
+ using the animate syntax works correctly.
+ """
+
+ class CustomAnimateScene(Scene):
+ def construct(self):
+ vt = ValueTracker(0)
+ vt.custom_attribute = "hello"
+ self.play(vt.animate.set_value(42).set(custom_attribute="world"))
+ assert vt.get_value() == 42
+ assert vt.custom_attribute == "world"
+
+ CustomAnimateScene().render()