Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Fixed bug with invalid color type ``None`` (#2584)

ad_chaosdb504a548b5a
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
index 7fac178f3..d7bb73134 100644
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -162,8 +162,8 @@ class VMobject(Mobject):
one color was passed in, a second slightly light color
will automatically be added for the gradient
"""
- colors = list(tuplify(color))
- opacities = list(tuplify(opacity))
+ colors = [c if (c is not None) else BLACK for c in tuplify(color)]
+ opacities = [o if (o is not None) else 0 for o in tuplify(opacity)]
rgbas = np.array(
[color_to_rgba(c, o) for c, o in zip(*make_even(colors, opacities))],
)
@@ -177,9 +177,7 @@ class VMobject(Mobject):
return rgbas
def update_rgbas_array(self, array_name, color=None, opacity=None):
- passed_color = color if (color is not None) else BLACK
- passed_opacity = opacity if (opacity is not None) else 0
- rgbas = self.generate_rgbas_array(passed_color, passed_opacity)
+ rgbas = self.generate_rgbas_array(color, opacity)
if not hasattr(self, array_name):
setattr(self, array_name, rgbas)
return self
diff --git a/tests/test_graphical_units/control_data/mobjects/match_style.npz b/tests/test_graphical_units/control_data/mobjects/match_style.npz
new file mode 100644
index 000000000..dcdad6d32
Binary files /dev/null and b/tests/test_graphical_units/control_data/mobjects/match_style.npz differ
diff --git a/tests/test_graphical_units/control_data/transform/ReplacementTransform.npz b/tests/test_graphical_units/control_data/transform/ReplacementTransform.npz
new file mode 100644
index 000000000..0edf7f2f6
Binary files /dev/null and b/tests/test_graphical_units/control_data/transform/ReplacementTransform.npz differ
diff --git a/tests/test_graphical_units/test_mobjects.py b/tests/test_graphical_units/test_mobjects.py
index 0ec5879b1..e5c531842 100644
--- a/tests/test_graphical_units/test_mobjects.py
+++ b/tests/test_graphical_units/test_mobjects.py
@@ -27,3 +27,12 @@ def test_become(scene):
s3 = s.copy().become(d3, stretch=True).set_opacity(0.25).set_color(YELLOW)
scene.add(s, d1, d2, d3, s1, s2, s3)
+
+
+@frames_comparison
+def test_match_style(scene):
+ square = Square(fill_color=[RED, GREEN], fill_opacity=1)
+ circle = Circle()
+ VGroup(square, circle).arrange()
+ circle.match_style(square)
+ scene.add(square, circle)
diff --git a/tests/test_graphical_units/test_transform.py b/tests/test_graphical_units/test_transform.py
index cfad32c36..aa13c3dcc 100644
--- a/tests/test_graphical_units/test_transform.py
+++ b/tests/test_graphical_units/test_transform.py
@@ -155,3 +155,11 @@ def test_MatchPointsScene(scene):
@frames_comparison(last_frame=False)
def test_AnimationBuilder(scene):
scene.play(Square().animate.shift(RIGHT).rotate(PI / 4))
+
+
+@frames_comparison(last_frame=False)
+def test_ReplacementTransform(scene):
+ v1 = Vector()
+ v2 = Vector()
+ v3 = Line()
+ scene.play(ReplacementTransform(VGroup(v1, v2), v3))