
    lj                        d Z ddlmZ ddgZddlmZ ddlZddlm	Z	 dd	l
mZ dd
lmZ ddlmZmZ ddlmZ  G d de          Z G d de          Z G d de          ZdS )a  Fading in and out of view.

.. manim:: Fading

    class Fading(Scene):
        def construct(self):
            tex_in = Tex("Fade", "In").scale(3)
            tex_out = Tex("Fade", "Out").scale(3)
            self.play(FadeIn(tex_in, shift=DOWN, scale=0.66))
            self.play(ReplacementTransform(tex_in, tex_out))
            self.play(FadeOut(tex_out, shift=DOWN * 2, scale=1.5))

    )annotationsFadeOutFadeIn)AnyN)OpenGLMobject   )	Transform)ORIGIN)GroupMobject)Scenec                  6     e Zd ZdZddddd fdZddZ xZS )_Fadea  Fade :class:`~.Mobject` s in or out.

    Parameters
    ----------
    mobjects
        The mobjects to be faded.
    shift
        The vector by which the mobject shifts while being faded.
    target_position
        The position to/from which the mobject moves while being faded in. In case
        another mobject is given as target position, its center is used.
    scale
        The factor by which the mobject is scaled initially before being rescaling to
        its original size while being faded in.

    N   )shifttarget_positionscalemobjectsr   r   np.ndarray | Noner   np.ndarray | Mobject | Noner   floatkwargsr   returnNonec                  |st          d          t          |          dk    r|d         nt          | }d| _        |X|Ot	          |t
          t          f          r|                                }||                                z
  }d| _        nt          }|| _	        || _
         t                      j        |fi | d S )Nz$At least one mobject must be passed.r   r   FT)
ValueErrorlenr   point_target
isinstancer   r   
get_centerr
   shift_vectorscale_factorsuper__init__)selfr   r   r   r   r   mobject	__class__s          Q/home/agentuser/manim-venv/lib/python3.11/site-packages/manim/animation/fading.pyr$   z_Fade.__init__4   s      	ECDDD!$X!!3!3(1++9I!=*o/GHH C&5&@&@&B&BO''*<*<*>*>>$(!!!!++F+++++    fadeInboolc                    | j                                         }|                    d           |r	| j        sdnd}|                    | j        |z             |                    | j                   |S )a   Create a faded, shifted and scaled copy of the mobject.

        Parameters
        ----------
        fadeIn
            Whether the faded mobject is used to fade in.

        Returns
        -------
        Mobject
            The faded, shifted and scaled copy of the mobject.
        r   )r&   copyfader   r   r!   r   r"   )r%   r*   faded_mobjectdirection_modifiers       r(   _create_faded_mobjectz_Fade._create_faded_mobjectM   s|     "&!2!2!4!41#)J$2CJRRD-0BBCCCD-...r)   )r   r   r   r   r   r   r   r   r   r   r   r   )r*   r+   r   r   )__name__
__module____qualname____doc__r$   r2   __classcell__r'   s   @r(   r   r   "   sp         ( $(7;, , , , , , , ,2       r)   r   c                  4     e Zd ZdZd fdZdd	Zdd
Z xZS )r   a  Fade in :class:`~.Mobject` s.

    Parameters
    ----------
    mobjects
        The mobjects to be faded in.
    shift
        The vector by which the mobject shifts while being faded in.
    target_position
        The position from which the mobject starts while being faded in. In case
        another mobject is given as target position, its center is used.
    scale
        The factor by which the mobject is scaled initially before being rescaling to
        its original size while being faded in.

    Examples
    --------

    .. manim :: FadeInExample

        class FadeInExample(Scene):
            def construct(self):
                dot = Dot(UP * 2 + LEFT)
                self.add(dot)
                tex = Tex(
                    "FadeIn with ", "shift ", r" or target\_position", " and scale"
                ).scale(1)
                animations = [
                    FadeIn(tex[0]),
                    FadeIn(tex[1], shift=DOWN),
                    FadeIn(tex[2], target_position=dot),
                    FadeIn(tex[3], scale=1.5),
                ]
                self.play(AnimationGroup(*animations, lag_ratio=0.5))

    r   r   r   r   r   r   c                >     t                      j        |ddi| d S )N
introducerTr#   r$   r%   r   r   r'   s      r(   r$   zFadeIn.__init__   s*    (>t>v>>>>>r)   c                    | j         S )N)r&   r%   s    r(   create_targetzFadeIn.create_target   s
    |r)   c                .    |                      d          S )NTr*   r2   r?   s    r(   create_starting_mobjectzFadeIn.create_starting_mobject   s    )))666r)   r   r   r   r   r   r   r   r   )r3   r4   r5   r6   r$   r@   rD   r7   r8   s   @r(   r   r   b   sp        # #J? ? ? ? ? ?   7 7 7 7 7 7 7 7r)   c                  8     e Zd ZdZd fdZdd	Zd fdZ xZS )r   aO  Fade out :class:`~.Mobject` s.

    Parameters
    ----------
    mobjects
        The mobjects to be faded out.
    shift
        The vector by which the mobject shifts while being faded out.
    target_position
        The position to which the mobject moves while being faded out. In case another
        mobject is given as target position, its center is used.
    scale
        The factor by which the mobject is scaled while being faded out.

    Examples
    --------

    .. manim :: FadeInExample

        class FadeInExample(Scene):
            def construct(self):
                dot = Dot(UP * 2 + LEFT)
                self.add(dot)
                tex = Tex(
                    "FadeOut with ", "shift ", r" or target\_position", " and scale"
                ).scale(1)
                animations = [
                    FadeOut(tex[0]),
                    FadeOut(tex[1], shift=DOWN),
                    FadeOut(tex[2], target_position=dot),
                    FadeOut(tex[3], scale=0.5),
                ]
                self.play(AnimationGroup(*animations, lag_ratio=0.5))


    r   r   r   r   r   r   c                >     t                      j        |ddi| d S )NremoverTr<   r=   s      r(   r$   zFadeOut.__init__   s*    (;D;F;;;;;r)   c                .    |                      d          S )NFrB   rC   r?   s    r(   r@   zFadeOut.create_target   s    )))777r)   scener   c                t    t                                          |           |                     d           d S )Nr   )r#   clean_up_from_sceneinterpolate)r%   rK   r'   s     r(   rM   zFadeOut.clean_up_from_scene   s5    ##E***r)   rE   rF   )rK   r   r   r   )r3   r4   r5   r6   r$   r@   rM   r7   r8   s   @r(   r   r      sz        # #J< < < < < <8 8 8 8         r)   )r6   
__future__r   __all__typingr   numpynp#manim.mobject.opengl.opengl_mobjectr   animation.transformr	   	constantsr
   mobject.mobjectr   r   scene.scener   r   r   r    r)   r(   <module>rZ      s<    # " " " " " 
           = = = = = = + + + + + +       , , , , , , , ,      = = = = =I = = =@-7 -7 -7 -7 -7U -7 -7 -7`. . . . .e . . . . .r)   