A community-maintained Python framework for creating mathematical animations.
Fix issue where SpiralIn doesn't show elements. (#3589)
Greg Ruppaa3e2cf54e6e
diff --git a/manim/animation/creation.py b/manim/animation/creation.pyindex 6f8173e35..2e15182bc 100644--- a/manim/animation/creation.py+++ b/manim/animation/creation.py@@ -456,7 +456,7 @@ class SpiralIn(Animation):fade_in_fraction=0.3,**kwargs,) -> None:- self.shapes = shapes+ self.shapes = shapes.copy()self.scale_factor = scale_factorself.shape_center = shapes.get_center()self.fade_in_fraction = fade_in_fraction@@ -473,15 +473,21 @@ class SpiralIn(Animation):def interpolate_mobject(self, alpha: float) -> None:alpha = self.rate_func(alpha)- for shape in self.shapes:+ for original_shape, shape in zip(self.shapes, self.mobject):shape.restore()- shape.save_state()- opacity = shape.get_fill_opacity()- new_opacity = min(opacity, alpha * opacity / self.fade_in_fraction)+ fill_opacity = original_shape.get_fill_opacity()+ stroke_opacity = original_shape.get_stroke_opacity()+ new_fill_opacity = min(+ fill_opacity, alpha * fill_opacity / self.fade_in_fraction+ )+ new_stroke_opacity = min(+ stroke_opacity, alpha * stroke_opacity / self.fade_in_fraction+ )shape.shift((shape.final_position - shape.initial_position) * alpha)shape.rotate(TAU * alpha, about_point=self.shape_center)shape.rotate(-TAU * alpha, about_point=shape.get_center_of_mass())- shape.set_opacity(new_opacity)+ shape.set_fill(opacity=new_fill_opacity)+ shape.set_stroke(opacity=new_stroke_opacity)class ShowIncreasingSubsets(Animation):diff --git a/tests/test_graphical_units/control_data/creation/SpiralIn.npz b/tests/test_graphical_units/control_data/creation/SpiralIn.npznew file mode 100644index 000000000..7b5806004Binary files /dev/null and b/tests/test_graphical_units/control_data/creation/SpiralIn.npz differdiff --git a/tests/test_graphical_units/test_creation.py b/tests/test_graphical_units/test_creation.pyindex c6cfc3e50..bcab0bafa 100644--- a/tests/test_graphical_units/test_creation.py+++ b/tests/test_graphical_units/test_creation.py@@ -94,3 +94,11 @@ def test_z_index_introducer(scene):b.set_z_index(-1)scene.play(Create(b))scene.wait()+++@frames_comparison(last_frame=False)+def test_SpiralIn(scene):+ circle = Circle().shift(LEFT)+ square = Square().shift(UP)+ shapes = VGroup(circle, square)+ scene.play(SpiralIn(shapes))