
    \
j                     >    d Z  G d d          Z G d d          ZdS )a  2D Animations

Animations can be used by the :py:class:`~pyglet.sprite.Sprite` class in place
of static images. They are essentially containers for individual image frames,
with a duration per frame. They can be infinitely looping, or stop at the last
frame. You can load Animations from disk, such as from GIF files::

    ani = pyglet.resource.animation('walking.gif')
    sprite = pyglet.sprite.Sprite(img=ani)

Alternatively, you can create your own Animations from a sequence of images
by using the :py:meth:`~Animation.from_image_sequence` method::

    images = [pyglet.resource.image('walk_a.png')
              pyglet.resource.image('walk_b.png')
              pyglet.resource.image('walk_c.png')]

    ani = pyglet.image.Animation.from_image_sequence(images, duration=0.1, loop=True)

You can also use an :py:class:`pyglet.image.ImageGrid`, which is iterable::

    sprite_sheet = pyglet.resource.image('my_sprite_sheet.png')
    image_grid = pyglet.image.ImageGrid(sprite_sheet, rows=1, columns=5)

    ani = pyglet.image.Animation.from_image_sequence(image_grid, duration=0.1)

In the above examples, all of the Animation Frames have the same duration.
If you wish to adjust this, you can manually create the Animation from a list of
:py:class:`~AnimationFrame`::

    image_a = pyglet.resource.image('walk_a.png')
    image_b = pyglet.resource.image('walk_b.png')
    image_c = pyglet.resource.image('walk_c.png')

    frame_a = pyglet.image.AnimationFrame(image_a, duration=0.1)
    frame_b = pyglet.image.AnimationFrame(image_b, duration=0.2)
    frame_c = pyglet.image.AnimationFrame(image_c, duration=0.1)

    ani = pyglet.image.Animation(frames=[frame_a, frame_b, frame_c])

c                   X    e Zd ZdZd ZddZddZd Zd Zd	 Z	e
dd            Zd ZdS )	Animationaf  Sequence of images with timing information.

    If no frames of the animation have a duration of ``None``, the animation
    loops continuously; otherwise the animation stops at the first frame with
    duration of ``None``.

    :Ivariables:
        `frames` : list of `~pyglet.image.AnimationFrame`
            The frames that make up the animation.

    c                 6    t          |          sJ || _        dS )zCreate an animation directly from a list of frames.

        :Parameters:
            `frames` : list of `~pyglet.image.AnimationFrame`
                The frames that make up the animation.

        N)lenframes)selfr   s     P/DATA/AppData/hermes/venv/lib/python3.11/site-packages/pyglet/image/animation.py__init__zAnimation.__init__\   s      6{{{        c                 Z    | j         D ]"}|                    |j        |          |_        #dS )a  Add the images of the animation to a :py:class:`~pyglet.image.atlas.TextureBin`.

        The animation frames are modified in-place to refer to the texture bin
        regions.

        :Parameters:
            `texture_bin` : `~pyglet.image.atlas.TextureBin`
                Texture bin to upload animation frames into.
            `border` : int
                Leaves specified pixels of blank space around
                each image frame when adding to the TextureBin.

        N)r   addimage)r   texture_binborderframes       r   add_to_texture_binzAnimation.add_to_texture_bing   s8     [ 	? 	?E%//%+v>>EKK	? 	?r
   Fc                 P    fd| j         D             }t          |          S )a  Create a copy of this animation applying a simple transformation.

        The transformation is applied around the image's anchor point of
        each frame.  The texture data is shared between the original animation
        and the transformed animation.

        :Parameters:
            `flip_x` : bool
                If True, the returned animation will be flipped horizontally.
            `flip_y` : bool
                If True, the returned animation will be flipped vertically.
            `rotate` : int
                Degrees of clockwise rotation of the returned animation.  Only
                90-degree increments are supported.

        :rtype: :py:class:`~pyglet.image.Animation`
        c           	          g | ]C}t          |j                                                                      |j                  DS  )AnimationFramer   get_textureget_transformduration).0r   flip_xflip_yrotates     r   
<listcomp>z+Animation.get_transform.<locals>.<listcomp>   sb     K K K5: !!8!8!:!:!H!HQWY_!`!`!&1 1 K K Kr
   )r   r   )r   r   r   r   r   s    ``` r   r   zAnimation.get_transformx   sP    $K K K K K K>BkK K K   r
   c                 >    t          d | j        D                       S )zSGet the total duration of the animation in seconds.

        :rtype: float
        c                 *    g | ]}|j         	|j         S )Nr   r   r   s     r   r   z*Animation.get_duration.<locals>.<listcomp>   s!    ZZZuu~?YEN?Y?Y?Yr
   )sumr   r   s    r   get_durationzAnimation.get_duration   s#    
 ZZZZZ[[[r
   c                 >    t          d | j        D                       S )zGet the maximum image frame width.

        This method is useful for determining texture space requirements: due
        to the use of ``anchor_x`` the actual required playback area may be
        larger.

        :rtype: int
        c                 &    g | ]}|j         j        S r   )r   widthr"   s     r   r   z+Animation.get_max_width.<locals>.<listcomp>   s    ???%EK%???r
   maxr   r$   s    r   get_max_widthzAnimation.get_max_width   s#     ??4;???@@@r
   c                 >    t          d | j        D                       S )zGet the maximum image frame height.

        This method is useful for determining texture space requirements: due
        to the use of ``anchor_y`` the actual required playback area may be
        larger.

        :rtype: int
        c                 &    g | ]}|j         j        S r   )r   heightr"   s     r   r   z,Animation.get_max_height.<locals>.<listcomp>   s    @@@5EK&@@@r
   r)   r$   s    r   get_max_heightzAnimation.get_max_height   s#     @@DK@@@AAAr
   Tc                 T    fd|D             }|sd|d         _          | |          S )a  Create an animation from a list of images and a constant framerate.

        :Parameters:
            `sequence` : list of `~pyglet.image.AbstractImage`
                Images that make up the animation, in sequence.
            `duration` : float
                Number of seconds to display each image.
            `loop` : bool
                If True, the animation will loop continuously.

        :rtype: :py:class:`~pyglet.image.Animation`
        c                 0    g | ]}t          |          S r   )r   )r   r   r   s     r   r   z1Animation.from_image_sequence.<locals>.<listcomp>   s#    HHHe.11HHHr
   Nr!   )clssequencer   loopr   s     `  r   from_image_sequencezAnimation.from_image_sequence   sA     IHHHxHHH 	'"&F2Js6{{r
   c                 P    d                     t          | j                            S )NzAnimation(frames={0}))formatr   r   r$   s    r   __repr__zAnimation.__repr__   s     &--c$+.>.>???r
   N)r   )FFr   )T)__name__
__module____qualname____doc__r	   r   r   r%   r+   r/   classmethodr6   r9   r   r
   r   r   r   O   s        
 
	 	 	? ? ? ?"! ! ! !,\ \ \	A 	A 	A	B 	B 	B    [$@ @ @ @ @r
   r   c                   "    e Zd ZdZdZd Zd ZdS )r   zA single frame of an animation.r   r   c                 "    || _         || _        dS )aB  Create an animation frame from an image.

        :Parameters:
            `image` : `~pyglet.image.AbstractImage`
                The image of this frame.
            `duration` : float
                Number of seconds to display the frame, or ``None`` if it is
                the last frame in the animation.

        Nr@   )r   r   r   s      r   r	   zAnimationFrame.__init__   s     
 r
   c                 B    d                     | j        | j                  S )Nz!AnimationFrame({0}, duration={1}))r8   r   r   r$   s    r   r9   zAnimationFrame.__repr__   s    299$*dmTTTr
   N)r:   r;   r<   r=   	__slots__r	   r9   r   r
   r   r   r      sB        ))#I! ! !U U U U Ur
   r   N)r=   r   r   r   r
   r   <module>rD      s   H( (Vp@ p@ p@ p@ p@ p@ p@ p@fU U U U U U U U U Ur
   