
    lj                        d Z ddlmZ dgZddlmZ ddlmZ ddlm	Z	 ddl
mZ dd	lmZ dd
lmZ ddlmZ ddlmZ  G d de          ZdS )a  A scene whose camera can be moved around.

.. SEEALSO::

    :mod:`.moving_camera`


Examples
--------

.. manim:: ChangingCameraWidthAndRestore

    class ChangingCameraWidthAndRestore(MovingCameraScene):
        def construct(self):
            text = Text("Hello World").set_color(BLUE)
            self.add(text)
            self.camera.frame.save_state()
            self.play(self.camera.frame.animate.set(width=text.width * 1.2))
            self.wait(0.3)
            self.play(Restore(self.camera.frame))


.. manim:: MovingCameraCenter

    class MovingCameraCenter(MovingCameraScene):
        def construct(self):
            s = Square(color=RED, fill_opacity=0.5).move_to(2 * LEFT)
            t = Triangle(color=GREEN, fill_opacity=0.5).move_to(2 * RIGHT)
            self.wait(0.3)
            self.add(s, t)
            self.play(self.camera.frame.animate.move_to(s))
            self.wait(0.3)
            self.play(self.camera.frame.animate.move_to(t))


.. manim:: MovingAndZoomingCamera

    class MovingAndZoomingCamera(MovingCameraScene):
        def construct(self):
            s = Square(color=BLUE, fill_opacity=0.5).move_to(2 * LEFT)
            t = Triangle(color=YELLOW, fill_opacity=0.5).move_to(2 * RIGHT)
            self.add(s, t)
            self.play(self.camera.frame.animate.move_to(s).set(width=s.width*2))
            self.wait(0.3)
            self.play(self.camera.frame.animate.move_to(t).set(width=t.width*2))

            self.play(self.camera.frame.animate.move_to(ORIGIN).set(width=14))

.. manim:: MovingCameraOnGraph

    class MovingCameraOnGraph(MovingCameraScene):
        def construct(self):
            self.camera.frame.save_state()

            ax = Axes(x_range=[-1, 10], y_range=[-1, 10])
            graph = ax.plot(lambda x: np.sin(x), color=WHITE, x_range=[0, 3 * PI])

            dot_1 = Dot(ax.i2gp(graph.t_min, graph))
            dot_2 = Dot(ax.i2gp(graph.t_max, graph))
            self.add(ax, graph, dot_1, dot_2)

            self.play(self.camera.frame.animate.scale(0.5).move_to(dot_1))
            self.play(self.camera.frame.animate.move_to(dot_2))
            self.play(Restore(self.camera.frame))
            self.wait()

.. manim:: SlidingMultipleScenes

    class SlidingMultipleScenes(MovingCameraScene):
        def construct(self):
            def create_scene(number):
                frame = Rectangle(width=16,height=9)
                circ = Circle().shift(LEFT)
                text = Tex(f"This is Scene {str(number)}").next_to(circ, RIGHT)
                frame.add(circ,text)
                return frame

            group = VGroup(*(create_scene(i) for i in range(4))).arrange_in_grid(buff=4)
            self.add(group)
            self.camera.auto_zoom(group[0], animate=False)
            for scene in group:
                self.play(self.camera.auto_zoom(scene))
                self.wait()

            self.play(self.camera.auto_zoom(group, margin=2))
    )annotationsMovingCameraScene)Any)	Animation)Mobject   )Camera)MovingCamera)Scene)extract_mobject_family_members)list_updatec                  4     e Zd ZdZefd fdZd fdZ xZS )r   aa  
    This is a Scene, with special configurations and properties that
    make it suitable for cases where the camera must be moved around.

    Note: Examples are included in the moving_camera_scene module
    documentation, see below in the 'see also' section.

    .. SEEALSO::

        :mod:`.moving_camera_scene`
        :class:`.MovingCamera`
    camera_classtype[Camera]kwargsr   returnNonec                >     t                      j        dd|i| d S )Nr    )super__init__)selfr   r   	__class__s      Z/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/scene/moving_camera_scene.pyr   zMovingCameraScene.__init__v   s-     	==l=f=====    
animationsr   list[Mobject]c                     t                      j        | }t          |          }| j        j                                        }|D ]}||v rt          | j        |          c S |S )a  
        This method returns a list of all of the Mobjects in the Scene that
        are moving, that are also in the animations passed.

        Parameters
        ----------
        *animations
            The Animations whose mobjects will be checked.
        )r   get_moving_mobjectsr   renderercamera get_mobjects_indicating_movementr   mobjects)r   r   moving_mobjectsall_moving_mobjectsmovement_indicatorsmovement_indicatorr   s         r   r   z%MovingCameraScene.get_moving_mobjects{   s     6%''5zB<_MM"m2SSUU"5 	C 	C!%888 #4=/BBBBB 9 r   )r   r   r   r   r   r   )r   r   r   r   )__name__
__module____qualname____doc__r
   r   r   __classcell__)r   s   @r   r   r   h   so          ,8> > > > > > >
         r   N)r+   
__future__r   __all__typingr   manim.animation.animationr   manim.mobject.mobjectr   camera.camerar	   camera.moving_camerar
   scene.scener   utils.familyr   utils.iterablesr   r   r   r   r   <module>r7      s   U Un # " " " " "
       / / / / / / ) ) ) ) ) ) " " " " " " / / / / / /       9 9 9 9 9 9 ) ) ) ) ) )% % % % % % % % % %r   