Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

can't pass list of colors in set_color() fixed (#993)

sparshgff1696c06593
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
index f27f5a476..ed187be11 100644
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -280,7 +280,12 @@ class VMobject(Mobject):
def set_color(self, color, family=True):
self.set_fill(color, family=family)
self.set_stroke(color, family=family)
- self.color = colour.Color(color)
+
+ # check if a list of colors is passed to color
+ if isinstance(color, str):
+ self.color = colour.Color(color)
+ else:
+ self.color = color
return self
def set_opacity(self, opacity, family=True):
diff --git a/tests/control_data/graphical_units_data/modifier_methods/GradientTest.npz b/tests/control_data/graphical_units_data/modifier_methods/GradientTest.npz
new file mode 100644
index 000000000..c3b32892c
Binary files /dev/null and b/tests/control_data/graphical_units_data/modifier_methods/GradientTest.npz differ
diff --git a/tests/test_graphical_units/test_modifier_methods.py b/tests/test_graphical_units/test_modifier_methods.py
new file mode 100644
index 000000000..e998a9293
--- /dev/null
+++ b/tests/test_graphical_units/test_modifier_methods.py
@@ -0,0 +1,19 @@
+import pytest
+
+from manim import *
+from ..utils.testing_utils import get_scenes_to_test
+from ..utils.GraphicalUnitTester import GraphicalUnitTester
+
+
+class GradientTest(Scene):
+ def construct(self):
+ c = Circle(fill_opacity=1).set_color(color=[YELLOW, GREEN])
+ self.play(Animation(c))
+
+
+MODULE_NAME = "modifier_methods"
+
+
[email protected]("scene_to_test", get_scenes_to_test(__name__), indirect=False)
+def test_scene(scene_to_test, tmpdir, show_diff):
+ GraphicalUnitTester(scene_to_test[1], MODULE_NAME, tmpdir).test(show_diff=show_diff)