Repository: ManimCommunity/manim
File: manim/animation/creation.py (Python)

Code before:
class SpiralIn(Animation):
    r"""Create the Mobject with sub-Mobjects flying in on spiral trajectories.

    Parameters
    ----------
    scale_factor
        The factor used for scaling the effect.

    Examples
    --------
    .. manim :: SpiralInExample

    class SpiralInExample(Scene):
        def construct(self):
            pi = MathTex(r"\pi").scale(7)
            pi.shift(2.25 * LEFT + 1.5 * UP)
            circle = Circle(color=GREEN_C, fill_opacity=1).shift(LEFT)
            square = Square(color=BLUE_D, fill_opacity=1).shift(UP)
            shapes = VGroup(pi, circle, square)
            self.play(SpiralIn(shapes))
    """

    def __init__(
        self,
        shapes: Mobject,
        scale_factor=1,
        **kwargs,
    ) -> None:
        self.shapes = shapes
        self.scale_factor = scale_factor
        expansion_factor = 8 * self.scale_factor
        self.shape_center = shapes.get_center()
        for shape in shapes:
            shape.final_position = shape.get_center()
            shape.initial_position = (
                shape.final_position
                + (shape.final_position - self.shape_center) * expansion_factor
            )
            shape.move_to(shape.initial_position)
            shape.save_state()

        super().__init__(shapes, **kwargs)

    def interpolate_mobject(self, alpha: float) -> None:
        TAU = 2 * np.pi
        for shape in self.shapes:
            shape.restore()
            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(min(1, alpha * 3))

Review comment (suggestion):
```suggestion
        scale_factor: float=1,
```

Code after:
            run_time,
            lag_ratio,
        )
        super().__init__(
            vmobject,
            run_time=run_time,
            lag_ratio=lag_ratio,
            rate_func=lambda t: -rate_func(t) + 1,
            reverse=reverse,
            **kwargs,
        )


class SpiralIn(Animation):
    r"""Create the Mobject with sub-Mobjects flying in on spiral trajectories.

    Parameters
    ----------
    shapes
        The Mobject on which to be operated.

    scale_factor
        The factor used for scaling the effect.

    fade_in_fraction
        Fractional duration of initial fade-in of sub-Mobjects as they fly inward.

    Examples
    --------
    .. manim :: SpiralInExample

        class SpiralInExample(Scene):
            def construct(self):
                pi = MathTex(r"\pi").scale(7)
                pi.shift(2.25 * LEFT + 1.5 * UP)
                circle = Circle(color=GREEN_C, fill_opacity=1).shift(LEFT)
                square = Square(color=BLUE_D, fill_opacity=1).shift(UP)
                shapes = VGroup(pi, circle, square)
                self.play(SpiralIn(shapes))
    """

    def __init__(
        self,
        shapes: Mobject,
        scale_factor: float = 8,
        fade_in_fraction=0.3,
        **kwargs,
    ) -> None:
        self.shapes = shapes
        self.scale_factor = scale_factor
        self.shape_center = shapes.get_center()