
    ^jp                       U d Z ddlmZ ddlZddlZddlmZmZmZ ddl	Z	ddl	m
Z
mZmZmZ ddlmZmZmZmZmZmZmZmZmZmZ  eed          oej        ZerddlmZmZ dd	lm Z  dd
l!m"Z"m#Z#m$Z$ dZ%de&d<   dZ'de&d<   dZ(de&d<   ddZ)ddZ* G d dej                  Z+ G d dej,                  Z-e-.                    d           dS )a	  Display positioned, scaled and rotated images.

A sprite is an instance of an image displayed on-screen.  Multiple sprites can
display the same image at different positions on the screen.  Sprites can also
be scaled larger or smaller, rotated at any angle and drawn at a fractional
opacity.

The following complete example loads a ``"ball.png"`` image and creates a
sprite for that image.  The sprite is then drawn in the window's
draw event handler::

    import pyglet

    ball_image = pyglet.image.load('ball.png')
    ball = pyglet.sprite.Sprite(ball_image, x=50, y=50)

    window = pyglet.window.Window()

    @window.event
    def on_draw():
        ball.draw()

    pyglet.app.run()

The sprite can be moved by modifying the :py:attr:`~pyglet.sprite.Sprite.x` and
:py:attr:`~pyglet.sprite.Sprite.y` properties.  Other
properties determine the sprite's :py:attr:`~pyglet.sprite.Sprite.rotation`,
:py:attr:`~pyglet.sprite.Sprite.scale` and
:py:attr:`~pyglet.sprite.Sprite.opacity`.

By default, sprite coordinates are restricted to integer values to avoid
sub-pixel artifacts.  If you require to use floats, for example for smoother
animations, you can set the ``subpixel`` parameter to ``True`` when creating
the sprite (:since: pyglet 1.2).

The sprite's positioning, rotation and scaling all honor the original
image's anchor (:py:attr:`~pyglet.image.AbstractImage.anchor_x`,
:py:attr:`~pyglet.image.AbstractImage.anchor_y`).


Drawing multiple sprites
========================

Sprites can be "batched" together and drawn at once more quickly than if each
of their ``draw`` methods were called individually.  The following example
creates one hundred ball sprites and adds each of them to a :py:class:`~pyglet.graphics.Batch`.  The
entire batch of sprites is then drawn in one call::

    batch = pyglet.graphics.Batch()

    ball_sprites = []
    for i in range(100):
        x, y = i * 10, 50
        ball_sprites.append(pyglet.sprite.Sprite(ball_image, x, y, batch=batch))

    @window.event
    def on_draw():
        batch.draw()

Sprites can be freely modified in any way even after being added to a batch,
however a sprite can belong to at most one batch.  See the documentation for
:py:mod:`pyglet.graphics` for more details on batched rendering, and grouping of
sprites within batches.

.. versionadded:: 1.1
    )annotationsN)TYPE_CHECKINGClassVarLiteral)clockeventgraphicsimage)
GL_BLENDGL_ONE_MINUS_SRC_ALPHAGL_SRC_ALPHAGL_TEXTURE0GL_TRIANGLESglActiveTextureglBindTextureglBlendFunc	glDisableglEnableis_pyglet_doc_run)BatchGroup)ShaderProgram)AbstractImage	AnimationTexturea  #version 150 core
    in vec3 translate;
    in vec4 colors;
    in vec3 tex_coords;
    in vec2 scale;
    in vec3 position;
    in float rotation;

    out vec4 vertex_colors;
    out vec3 texture_coords;

    uniform WindowBlock
    {
        mat4 projection;
        mat4 view;
    } window;

    mat4 m_scale = mat4(1.0);
    mat4 m_rotation = mat4(1.0);
    mat4 m_translate = mat4(1.0);

    void main()
    {
        m_scale[0][0] = scale.x;
        m_scale[1][1] = scale.y;
        m_translate[3][0] = translate.x;
        m_translate[3][1] = translate.y;
        m_translate[3][2] = translate.z;
        m_rotation[0][0] =  cos(-radians(rotation)); 
        m_rotation[0][1] =  sin(-radians(rotation));
        m_rotation[1][0] = -sin(-radians(rotation));
        m_rotation[1][1] =  cos(-radians(rotation));

        gl_Position = window.projection * window.view * m_translate * m_rotation * m_scale * vec4(position, 1.0);

        vertex_colors = colors;
        texture_coords = tex_coords;
    }
strvertex_sourcez#version 150 core
    in vec4 vertex_colors;
    in vec3 texture_coords;
    out vec4 final_colors;

    uniform sampler2D sprite_texture;

    void main()
    {
        final_colors = texture(sprite_texture, texture_coords.xy) * vertex_colors;
    }
fragment_sourcez#version 150 core
    in vec4 vertex_colors;
    in vec3 texture_coords;
    out vec4 final_colors;

    uniform sampler2DArray sprite_texture;

    void main()
    {
        final_colors = texture(sprite_texture, texture_coords) * vertex_colors;
    }
fragment_array_sourcereturnr   c                 h    t           j        j                            t          dft
          df          S )z~Create and return the default sprite shader.

    This method allows the module to be imported without an OpenGL Context.
    vertexfragment)pygletglcurrent_contextcreate_programr   r        H/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/sprite.pyget_default_shaderr+      s3    
 9$33]H4M5Dj4QS S Sr)   c                 h    t           j        j                            t          dft
          df          S )zCreate and return the default array sprite shader.

    This method allows the module to be imported without an OpenGL Context.
    r"   r#   )r$   r%   r&   r'   r   r   r(   r)   r*   get_default_array_shaderr-      s3    
 9$33]H4M5JJ4WY Y Yr)   c                  P     e Zd ZdZ	 dd fdZddZddZddZddZddZ	 xZ
S )SpriteGroupzShared Sprite rendering Group.

    The Group defines custom ``__eq__`` and ``__hash__`` methods, and so will
    be automatically coalesced with other Sprite Groups sharing the same parent
    Group, Texture and blend parameters.
    Ntexturer   	blend_srcint
blend_destprogramr   parentGroup | Noner    Nonec                    t                                          |           || _        || _        || _        || _        dS )a  Create a sprite group.

        The group is created internally when a :py:class:`~pyglet.sprite.Sprite`
        is created; applications usually do not need to explicitly create it.

        Args:
            texture:
                The (top-level) texture containing the sprite image.
            blend_src:
                OpenGL blend source mode; for example,
                ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example,
                ``GL_ONE_MINUS_SRC_ALPHA``.
            program:
                A custom ShaderProgram.
            parent:
                Optional parent group.
        )r5   N)super__init__r0   r1   r3   r4   )selfr0   r1   r3   r4   r5   	__class__s         r*   r:   zSpriteGroup.__init__   s@    * 	'''"$r)   c                   | j                                          t          t                     t	          | j        j        | j        j                   t          t                     t          | j        | j                   d S N)r4   user   r   r   r0   targetidr   r   r   r1   r3   r;   s    r*   	set_statezSpriteGroup.set_state   se    $$$dl)4<?;;;DNDO44444r)   c                `    t          t                     | j                                         d S r>   )r   r   r4   stoprB   s    r*   unset_statezSpriteGroup.unset_state   s*    (r)   r   c                0    | j         j         d| j         dS )N())r<   __name__r0   rB   s    r*   __repr__zSpriteGroup.__repr__   s     .);;DL;;;;r)   otherboolc                   |j         | j         u oq| j        |j        u oc| j        |j        k    oS| j        j        |j        j        k    o9| j        j        |j        j        k    o| j        |j        k    o| j        |j        k    S r>   )r<   r4   r5   r0   r@   rA   r1   r3   )r;   rL   s     r*   __eq__zSpriteGroup.__eq__   s    4>1 4-4u|+4 #u}';;4 5=#33	4
 %/14 5#33	5r)   c                |    t          | j        | j        | j        j        | j        j        | j        | j        f          S r>   )hashr4   r5   r0   rA   r@   r1   r3   rB   s    r*   __hash__zSpriteGroup.__hash__   s8    T\4;\_dl&9^T_6 7 7 	7r)   r>   )r0   r   r1   r2   r3   r2   r4   r   r5   r6   r    r7   r    r7   )r    r   )rL   r/   r    rM   r    r2   )rJ   
__module____qualname____doc__r:   rC   rF   rK   rO   rR   __classcell__)r<   s   @r*   r/   r/      s          AE      65 5 5 5   < < < <5 5 5 57 7 7 7 7 7 7 7r)   r/   c            	      d   e Zd ZU dZdZdZdZdZdZdZ	de
d<   dZdZdZd	ZdZeZd
e
d<   dddeeddddf	dmdZdnd Zdnd!Zdod#Zedpd%            Zej        dqd'            Zedrd)            Zej        dsd*            Zedtd,            Zej        dud-            Zedvd/            Zej        dwd0            Zedxd1            Zej        dyd2            Zdzd5Zdnd6Z d{d8Z!dnd9Z"d|d;Z#ed}d=            Z$e$j        d~d?            Z$edd@            Z%e%j        ddA            Z%eddB            Z&e&j        ddC            Z&eddD            Z'e'j        ddE            Z'eddF            Z(e(j        ddH            Z(eddI            Z)e)j        ddK            Z)eddL            Z*e*j        ddN            Z*eddO            Z+e+j        ddQ            Z+	 	 	 dddSZ,eddT            Z-e-j        ddV            Z-eddW            Z.e.j        ddY            Z.eddZ            Z/e/j        dd\            Z/edd]            Z0e0j        dd`            Z0edda            Z1e1j        ddc            Z1eddd            Z2e2j        ddf            Z2eddg            Z3e3j        ddi            Z3dndjZ4e5rddlZ6dS dS )SpritezPManipulate an on-screen image.

    See the module documentation for usage.
    Nr   F)   r[   r[   r[   tuple[int, int, int, int]_rgbag      ?Tz#ClassVar[type[SpriteGroup | Group]]group_classimgAbstractImage | Animationxfloatyzr1   r2   r3   batchBatch | Nonegroupr6   subpixelrM   r4   ShaderProgram | Noner    r7   c                   || _         || _        || _        t          |t          j                  rn|| _        |j        d         j                                        | _	        |j        d         j
        | _        | j        rt          j        | j        | j                   n|                                | _	        |
s7t          |t          j                  rt!                      }
nt#                      }
|
| _        || _        || _        || _        || _        |                                 | _        |	| _        |                                  dS )a  Create a Sprite instance.

        Args:
            img:
                Image or Animation to display.
            x:
                X coordinate of the sprite.
            y:
                Y coordinate of the sprite.
            z:
                Z coordinate of the sprite.
            blend_src:
                OpenGL blend source mode.  The default is suitable for
                compositing sprites drawn from back-to-front.
            blend_dest:
                OpenGL blend destination mode.  The default is suitable for
                compositing sprites drawn from back-to-front.
            batch:
                Optional batch to add the sprite to.
            group:
                Optional parent group of the sprite.
            subpixel:
                Allow floating-point coordinates for the sprite. By default,
                coordinates are restricted to integer values.
            program:
                A specific shader program to initialize the sprite with. By default, a pre-made shader will be chosen
                based on the texture type passed.

        .. versionadded:: 2.0.16
           The *program* parameter.
        r   N)_x_y_z
isinstancer
   r   
_animationframesget_texture_textureduration_next_dtr   schedule_once_animateTextureArrayRegionr-   r+   _program_batch
_blend_src_blend_dest_user_groupget_sprite_group_group	_subpixel_create_vertex_list)r;   r_   ra   rc   rd   r1   r3   re   rg   rh   r4   s              r*   r:   zSprite.__init__  s!   P c5?++ 	.!DOJqM/;;==DMJqM2DM} B#DM4=AAAOO--DM 	/#u788 /244,..#% ++--!  """""r)   c                n    	 | j         | j                                          d S d S # t          $ r Y d S w xY wr>   )_vertex_listdelete	ExceptionrB   s    r*   __del__zSprite.__del__O  sU    	 ,!((***** -, 	 	 	DD	s    & 
44c                    | j         rt          j        | j                   | j                                         d| _        d| _        d| _        dS )a	  Force immediate removal of the sprite from video memory.

        It is recommended to call this whenever you delete a sprite,
        as the Python garbage collector will not necessarily call the
        finalizer as soon as the sprite falls out of scope.
        N)ro   r   
unschedulerv   r   r   rr   r~   rB   s    r*   r   zSprite.deleteV  sR     ? 	,T]+++  """  r)   dtc                "   | xj         dz  c_         | j         t          | j        j                  k    r%d| _         |                     d           | j        d S | j        j        | j                  }|                     |j                                                   |j	        X|j	        | j
        |z
  z
  }t          t          d|          |j	                  }t          j        | j        |           || _
        d S |                     d           d S )N   r   on_animation_end)_frame_indexlenro   rp   dispatch_eventr   _set_texturer
   rq   rs   rt   minmaxr   ru   rv   )r;   r   framers   s       r*   rv   zSprite._animatef  s   QDO$: ; ;;; !D 2333 (&t'89%+1133444>%~);<H3q(++U^<<Hx888$DMMM 233333r)   tuple[int, int]c                    | j         | j        fS )zThe current blend mode applied to this sprite.

        .. note:: Changing this can be an expensive operation as it involves a group creation and transfer.
        )rz   r{   rB   s    r*   
blend_modezSprite.blend_modey  s      000r)   modesc                   |\  }}|| j         k    r|| j        k    rd S || _         || _        |                                 | _        | j        3| j                            | j        t          | j        | j                   d S d S r>   )rz   r{   r}   r~   ry   migrater   r   )r;   r   srcdsts       r*   r   zSprite.blend_mode  s    S$/!!cT-=&=&=F++--;"K 1<dkZZZZZ #"r)   r   c                    | j         S )zThe current shader program.

        .. note:: Changing this can be an expensive operation as it involves a group creation and transfer.
        )rx   rB   s    r*   r4   zSprite.program  s     }r)   c                $   | j         |k    rd S || _         |                                 | _        | j        r.| j                            | j        t          | j        |          rd S | j                                         |                                  d S r>   )	rx   r}   r~   ry   update_shaderr   r   r   r   )r;   r4   s     r*   r4   zSprite.program  s    =G##F++--K 	))$*;\4;X_``	 F 	  """  """""r)   r   c                    | j         S )a  Graphics batch.

        The sprite can be migrated from one batch to another, or removed from
        its batch (for individual drawing).

        .. note:: Changing this can be an expensive operation as it involves deleting the vertex list and recreating it.
        )ry   rB   s    r*   re   zSprite.batch  s     {r)   c                   | j         |k    rd S |<| j         5| j                             | j        t          | j        |           || _         d S | j                                         || _         |                                  d S r>   )ry   r   r   r   r~   r   r   )r;   re   s     r*   re   zSprite.batch  s    ;%F!8K 1<eTTTDKKK$$&&&DK$$&&&&&r)   r   c                    | j         S )zParent graphics group specified by the user.

        This group will always be the parent of the internal sprite group.

        .. note:: Changing this can be an expensive operation as it involves a group creation and transfer.
        )r|   rB   s    r*   rg   zSprite.group  s     r)   c                    | j         |k    rd S || _         |                                 | _        | j        3| j                            | j        t          | j        | j                   d S d S r>   )r|   r}   r~   ry   r   r   r   )r;   rg   s     r*   rg   zSprite.group  si    u$$F ++--;"K 1<dkZZZZZ #"r)   c                ,    | j         r| j         S | j        S )zThe Sprite's Image or Animation to display.

        .. note:: Changing this can be an expensive operation if the texture is not part of the same texture or atlas.
        )ro   rr   rB   s    r*   r
   zSprite.image  s     ? 	#?"}r)   c                   | j          t          j        | j                   d | _         t	          |t
          j                  r|| _         d| _        |                     |j	        d         j        
                                           |j	        d         j        | _        | j        rt          j        | j        | j                   n'|                     |
                                           |                                  d S )Nr   )ro   r   r   rv   rn   r
   r   r   r   rp   rq   rs   rt   ru   _update_position)r;   r_   s     r*   r
   zSprite.image  s    ?&T]+++"DOc5?++ 	1!DO !Dcjm1==??@@@JqM2DM} B#DM4=AAAcoo//000r)   r0   r   c                   |j         | j        j         urN| j                                         || _        |                                 | _        |                                  n|j        | j        j        d d <   || _        d S r>   )rA   rr   r   r   r}   r~   r   
tex_coords)r;   r0   s     r*   r   zSprite._set_texture  sz    :T]---$$&&&#DM//11DK$$&&&&.5.@D(+r)   c                V   | j                             dt          g d| j        | j        d|                                 fd| j        dz  fd| j        | j        | j	        fdz  fd| j
        | j        z  | j
        | j        z  fdz  fd| j        fdz  fd| j        j        f          | _        d S )N   )r   r      r   r      fBn)positioncolors	translatescalerotationr   )r4   vertex_list_indexedr   ry   r~   _get_verticesr]   rk   rl   rm   _scale_scale_x_scale_y	_rotationrr   r   r   rB   s    r*   r   zSprite._create_vertex_list  s     L<<|///dk4--//0$*q.)TWdgtw7!;<t}4dkDM6QRUVVWDN,q01T]56 = 8 8r)   tuplec                   | j         sdS | j        }|j         }|j         }||j        z   }||j        z   }| j        svt          |          t          |          dt          |          t          |          dt          |          t          |          dt          |          t          |          dfS ||d||d||d||dfS )N)r   r   r   r   r   r   r   r   r   r   r   r   r   )_visiblerr   anchor_xanchor_ywidthheightr   r2   )r;   r_   x1y1x2y2s         r*   r   zSprite._get_vertices   s    } 	655ml]l]#)^#*_~ 	>GGSWWaR#b''1GGSWWaR#b''1> > 2q"b!RQB99r)   c                L    |                                  | j        j        d d <   d S r>   )r   r   r   rB   s    r*   r   zSprite._update_position  s(    (,(:(:(<(<"111%%%r)   SpriteGroup | Groupc                f    |                      | j        | j        | j        | j        | j                  S )a  Creates and returns a group to be used to render the sprite.

        This is used internally to create a consolidated group for rendering.

        .. note:: This is for advanced usage. This is a group automatically created internally as a child of ``group``,
                  and does not need to be modified unless the parameters of your custom group changes.

        .. versionadded:: 2.0.16
        )r^   rr   rz   r{   rx   r|   rB   s    r*   r}   zSprite.get_sprite_group  s/     t@PRVR_aeaqrrrr)   tuple[float, float, float]c                *    | j         | j        | j        fS )z4The (x, y, z) coordinates of the sprite, as a tuple.)rk   rl   rm   rB   s    r*   r   zSprite.position  s     w((r)   r   c                X    |\  | _         | _        | _        |dz  | j        j        d d <   d S Nr   rk   rl   rm   r   r   )r;   r   s     r*   r   zSprite.position$  s2    $,!$')1A#AAA&&&r)   c                    | j         S )zX coordinate of the sprite.)rk   rB   s    r*   ra   zSprite.x)       wr)   c                V    || _         || j        | j        fdz  | j        j        d d <   d S r   r   )r;   ra   s     r*   ra   zSprite.x.  s3    *+TWdg)>)B#AAA&&&r)   c                    | j         S )zY coordinate of the sprite.)rl   rB   s    r*   rc   zSprite.y3  r   r)   c                V    || _         | j        || j        fdz  | j        j        d d <   d S r   )rl   rk   rm   r   r   )r;   rc   s     r*   rc   zSprite.y8  s3    *.'1dg)>)B#AAA&&&r)   c                    | j         S )zZ coordinate of the sprite.)rm   rB   s    r*   rd   zSprite.z=  r   r)   c                V    || _         | j        | j        |fdz  | j        j        d d <   d S r   )rm   rk   rl   r   r   )r;   rd   s     r*   rd   zSprite.zB  s3    *.'47A)>)B#AAA&&&r)   c                    | j         S )zClockwise rotation of the sprite, in degrees.

        The sprite image will be rotated about its image's (anchor_x, anchor_y)
        position.
        )r   rB   s    r*   r   zSprite.rotationG  s     ~r)   r   c                H    || _         | j         fdz  | j        j        d d <   d S r   )r   r   r   )r;   r   s     r*   r   zSprite.rotationP  s-    !)-(9A(="111%%%r)   c                    | j         S )zBase Scaling factor.

        A scaling factor of 1.0 (the default) has no effect. A scale of
        2.0 will draw the sprite at twice the native size of its image.
        )r   rB   s    r*   r   zSprite.scaleU  s     {r)   r   c                `    || _         || j        z  || j        z  fdz  | j        j        d d <   d S r   )r   r   r   r   r   )r;   r   s     r*   r   zSprite.scale^  s<    &+dm&;UT]=R%SVW%W"""r)   c                    | j         S )zHorizontal scaling factor.

        A scaling factor of 1.0 (the default) has no effect. A scale of
        2.0 will draw the sprite at twice the native width of its image.
        )r   rB   s    r*   scale_xzSprite.scale_xc       }r)   r   c                j    || _         | j        |z  | j        | j        z  fdz  | j        j        d d <   d S r   )r   r   r   r   r   )r;   r   s     r*   r   zSprite.scale_xl  s>    &*kG&;T[4==X%Y\]%]"""r)   c                    | j         S )zVertical scaling factor.

        A scaling factor of 1.0 (the default) has no effect. A scale of
        2.0 will draw the sprite at twice the native height of its image.
        )r   rB   s    r*   scale_yzSprite.scale_yq  r   r)   r   c                j    || _         | j        | j        z  | j        |z  fdz  | j        j        d d <   d S r   )r   r   r   r   r   )r;   r   s     r*   r   zSprite.scale_yz  s?    &*kDM&A4;QXCX%Y\]%]"""r)   float | Nonec                   d}|	|| _         d}|	|| _        d}|	|| _        d}|r&| j         | j        | j        fdz  | j        j        dd<   |'|| j        k    r|| _        |fdz  | j        j        dd<   d}	|	|| _        d}	|	|| _        d}	|	|| _	        d}	|	r2| j        | j        z  | j        | j	        z  fdz  | j        j
        dd<   dS dS )a  Simultaneously change the position, rotation or scale.

        This method is provided for convenience. There is not much
        performance benefit to updating multiple Sprite attributes at once.

        Args:
            x:
                X coordinate of the sprite.
            y:
                Y coordinate of the sprite.
            z:
                Z coordinate of the sprite.
            rotation:
                Clockwise rotation of the sprite, in degrees.
            scale:
                Scaling factor.
            scale_x:
                Horizontal scaling factor.
            scale_y:
                Vertical scaling factor.

        .. deprecated:: 2.0.x
           No longer calculated with the vertices on the CPU. Now calculated within a shader.

           * Use ``x``, ``y``, ``z``, or ``position`` to update position.
           * Use ``rotation`` to update rotation.
           * Use ``scale_x``, ``scale_y``, or ``scale`` to update scale.
        FNTr   )rk   rl   rm   r   r   r   r   r   r   r   r   )
r;   ra   rc   rd   r   r   r   r   translations_outdatedscales_outdateds
             r*   updatezSprite.update  s/   > !& =DG$(!=DG$(!=DG$(!  	M.2gtw-H1-LD'*H$>$>%DN-5K!OD&qqq) DK"O#DM"O#DM"O 	h*.+*Et{UYUbGb)cfg)gD#AAA&&&	h 	hr)   c                    | j         j        t          | j                  z  t          | j                  z  }| j        r|nt          |          S )zGScaled width of the sprite.

        Invariant under rotation.
        )rr   r   absr   r   r   r2   )r;   ws     r*   r   zSprite.width  sC     M#dm"4"44s4;7G7GGN.qqA.r)   r   c                X    || j         j        t          | j                  z  z  | _        d S r>   )rr   r   r   r   r   )r;   r   s     r*   r   zSprite.width  s&     3c$+6F6F FGr)   c                    | j         j        t          | j                  z  t          | j                  z  }| j        r|nt          |          S )zHScaled height of the sprite.

        Invariant under rotation.
        )rr   r   r   r   r   r   r2   )r;   hs     r*   r   zSprite.height  sC     M 3t}#5#55DK8H8HHN.qqA.r)   r   c                X    || j         j        t          | j                  z  z  | _        d S r>   )rr   r   r   r   r   )r;   r   s     r*   r   zSprite.height  s&    !5DK8H8H!HIr)   c                    | j         d         S )a  Blend opacity.

        This property sets the alpha component of the colour of the sprite's
        vertices.  With the default blend mode (see the constructor), this
        allows the sprite to be drawn with fractional opacity, blending with the
        background.

        An opacity of 255 (the default) has no effect.  An opacity of 128 will
        make the sprite appear translucent.
        r   r]   rB   s    r*   opacityzSprite.opacity  s     z!}r)   r   c                f    | j         \  }}}}||||f| _         | j         dz  | j        j        d d <   d S r   r]   r   r   )r;   r   rgb_s         r*   r   zSprite.opacity  sA    Z
1a1g%
&*j1n ###r)   c                    | j         S )a?  Blend color.

        This property sets the color of the sprite's vertices. This allows the
        sprite to be drawn with a color tint.

        The color is specified as either an RGBA tuple of integers
        '(red, green, blue, opacity)' or an RGB tuple of integers
        `(red, blue, green)`.

        If there are fewer than three components, a :py:func`ValueError`
        will be raised. Each color component must be an int in the range
        0 (dark) to 255 (saturated). If any component is not an int, a
        :py:class:`TypeError` will be raised.
        r   rB   s    r*   colorzSprite.color  s      zr)   rgba0tuple[int, int, int, int] | tuple[int, int, int]c                    |^}}}}||||r|d         ndf}|| j         k    r|| _         |dz  | j        j        d d <   d S d S )Nr   r[   r   r   )r;   r   r   r   r   a	new_colors          r*   r   zSprite.color  sh     1a!q!Q/QqTTC/	 
"""DJ*3a-D$QQQ''' #"r)   c                    | j         S )z!True if the sprite will be drawn.)r   rB   s    r*   visiblezSprite.visible  s     }r)   r   c                <    || _         |                                  d S r>   )r   r   )r;   r   s     r*   r   zSprite.visible  s!    r)   c                    | j         S )zPause/resume the Sprite's Animation.

        If ``Sprite.image`` is an Animation, you can pause or resume
        the animation by setting this property to True or False.
        If not an Animation, this has no effect.
        )_pausedrB   s    r*   pausedzSprite.paused  s     |r)   pausec                   t          | d          r|| j        k    rd S |du rt          j        | j                   nI| j        j        | j                 }|j        | _	        | j	        rt          j
        | j        | j	                   || _        d S )Nro   T)hasattrr   r   r   rv   ro   rp   r   rs   rt   ru   )r;   r   r   s      r*   r   zSprite.paused!  s    t\** 	et|.C.CFD==T]++++O*4+<=E!NDM} B#DM4=AAAr)   c                    | j         S )zThe current Animation frame.

        If the ``Sprite.image`` is an ``Animation``, you can query or set
        the current frame. If not an Animation, this will always be 0.
        )r   rB   s    r*   frame_indexzSprite.frame_index.  s       r)   indexc           	        | j         dS t          dt          |t          | j         j                  dz
                      | _        | j         j        | j                 }|                     |j                                                   dS )a  Set the current Animation frame.

        Args:
            index:
                The desired frame index.

        Updates the currently displayed frame of an animation immediately even if
        the animation is paused.  If not an Animation, this has no effect.
        Nr   r   )	ro   r   r   r   rp   r   r   r
   rq   )r;   r  r   s      r*   r  zSprite.frame_index7  sy     ?"F3uc$/2H.I.IA.M#N#NOO&t'89%+113344444r)   c                    | j                                          | j                            t                     | j                                          dS )zDraw the sprite at its current position.

        See the module documentation for hints on drawing multiple sprites
        efficiently.
        N)r~   set_state_recursiver   drawr   unset_state_recursiverB   s    r*   r  zSprite.drawI  sI     	'')))|,,,))+++++r)   None | Literal[True]c                    dS )a  The sprite animation reached the final frame.

            The event is triggered only if the sprite has an animation, not an
            image.  For looping animations, the event is triggered each time
            the animation loops.

            :event:
            Nr(   rB   s    r*   r   zSprite.on_animation_endV  s      r)   )r_   r`   ra   rb   rc   rb   rd   rb   r1   r2   r3   r2   re   rf   rg   r6   rh   rM   r4   ri   r    r7   rS   )r   rb   r    r7   )r    r   )r   r   r    r7   r    r   )r4   r   r    r7   )r    r   )re   r   r    r7   )r    r   )rg   r   r    r7   )r    r`   )r_   r`   r    r7   )r0   r   r    r7   )r    r   )r    r   )r    r   )r   r   r    r7   )r    rb   )ra   rb   r    r7   )rc   rb   r    r7   )rd   rb   r    r7   )r   rb   r    r7   )r   rb   r    r7   )r   rb   r    r7   )r   rb   r    r7   )NNNNNNN)ra   r   rc   r   rd   r   r   r   r   r   r   r   r   r   r    r7   )r   rb   r    r7   )r   rb   r    r7   rT   )r   r2   )r    r\   )r   r   )r    rM   )r   rM   r    r7   )r   rM   r    r7   )r  r2   r    r7   )r    r
  )7rJ   rU   rV   rW   ry   ro   r   r   r   r]   __annotations__r   r   r   r   r   r/   r^   r   r   r:   r   r   rv   propertyr   setterr4   re   rg   r
   r   r   r   r   r}   r   ra   rc   rd   r   r   r   r   r   r   r   r   r   r   r   r  r  _is_pyglet_doc_runr   r(   r)   r*   rZ   rZ      s         
 FJLGI';E;;;;FHHHL 8CKBBBB !".#9'+'+"'15B# B# B# B# B#H       4 4 4 4& 1 1 1 X1 
[ 
[ 
[ 
[    X ^# # # ^#    X \
' 
' 
' \
'       X  \[ [ [ \[    X \      \         8 8 8 8: : : : = = = =
s 
s 
s 
s ) ) ) X) _6 6 6 _6    X XC C C XC    X XC C C XC    X XC C C XC    X _> > > _>    X \X X X \X    X ^^ ^ ^ ^^    X ^^ ^ ^ ^^ X\DHEIAh Ah Ah Ah AhF / / / X/ \H H H \H / / / X/ ]J J J ]J    X ^5 5 5 ^5
    X" \8 8 8 \8    X ^      ^     X ]
 
 
 ]
 ! ! ! X! 5 5 5 5", , , ,  	 	 	 	 	 	 r)   rZ   r   r  )/rW   
__future__r   syswarningstypingr   r   r   r$   r   r   r	   r
   	pyglet.glr   r   r   r   r   r   r   r   r   r   r  r   r  pyglet.graphicsr   r   pyglet.graphics.shaderr   pyglet.imager   r   r   r   r  r   r   r+   r-   r/   EventDispatcherrZ   register_event_typer(   r)   r*   <module>r     sq  A A AD # " " " " " 



  3 3 3 3 3 3 3 3 3 3  0 0 0 0 0 0 0 0 0 0 0 0                        WS"566P3;P  ?,,,,,,,,444444>>>>>>>>>>& & & & &P         S S S SY Y Y Y?7 ?7 ?7 ?7 ?7(. ?7 ?7 ?7Dh	 h	 h	 h	 h	U" h	 h	 h	V   - . . . . .r)   