
    ^j                      d Z ddlmZ ddlZddlmZmZ ddlmZm	Z	m
Z
mZ ddlZddlmZ ddlmZmZmZmZmZmZmZ ddlmZmZ dd	lmZ erdd
lmZ dZdZdGdZ dHdZ!dIdZ"	 dJdKd%Z# G d& d'e          Z$ G d( d)e          Z% G d* d+e%          Z& G d, d-e%          Z' G d. d/e%          Z( G d0 d1e%          Z) G d2 d3e%          Z* G d4 d5e%          Z+ G d6 d7e%          Z, G d8 d9e%          Z- G d: d;e%          Z.ee/e
e/e/f         f         Z0 G d< d=ej1        j%                  Z2 G d> d?e%          Z3 G d@ dAe%          Z4 G dB dCe%          Z5 G dD dEe%          Z6dFZ7dS )La  2D shapes.

This module provides classes for a variety of simplistic 2D shapes,
such as Rectangles, Circles, and Lines. These shapes are made
internally from OpenGL primitives, and provide excellent performance
when drawn as part of a :py:class:`~pyglet.graphics.Batch`.
Convenience methods are provided for positioning, changing color, opacity,
and rotation.
The Python ``in`` operator can be used to check whether a point is inside a shape.
(This is approximated with some shapes, such as Star).

If the shapes in this module don't suit your needs, you have two
options:

.. list-table::
   :header-rows: 1

   * - Your Goals
     - Best Approach

   * - Simple shapes like those here
     - Subclass :py:class:`ShapeBase`

   * - Complex & optimized shapes
     - See :ref:`guide_graphics` to learn about
       the low-level graphics API.


A simple example of drawing shapes::

    import pyglet
    from pyglet import shapes

    window = pyglet.window.Window(960, 540)
    batch = pyglet.graphics.Batch()

    circle = shapes.Circle(700, 150, 100, color=(50, 225, 30), batch=batch)
    square = shapes.Rectangle(200, 200, 200, 200, color=(55, 55, 255), batch=batch)
    rectangle = shapes.Rectangle(250, 300, 400, 200, color=(255, 22, 20), batch=batch)
    rectangle.opacity = 128
    rectangle.rotation = 33
    line = shapes.Line(100, 100, 100, 200, thickness=19, batch=batch)
    line2 = shapes.Line(150, 150, 444, 111, thickness=4, color=(200, 20, 20), batch=batch)
    star = shapes.Star(800, 400, 60, 40, num_spikes=20, color=(255, 255, 0), batch=batch)

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

    pyglet.app.run()


.. note:: Some Shapes, such as :py:class:`.Line` and :py:class:`.Triangle`,
          have multiple coordinates.

          These shapes treat their :py:attr:`~ShapeBase.position` as their
          primary coordinate. Changing it or its components (the
          :py:attr:`~ShapeBase.x` or :py:attr:`~ShapeBase.y` properties)
          also moves all secondary coordinates by the same offset from
          the previous :py:attr:`~ShapeBase.position` value. This allows
          you to move these shapes without distorting them.


.. versionadded:: 1.5.4
    )annotationsN)ABCabstractmethod)TYPE_CHECKINGSequenceTupleUnion)earcut)GL_BLENDGL_ONE_MINUS_SRC_ALPHAGL_SRC_ALPHAGL_TRIANGLESglBlendFunc	glDisableglEnable)BatchGroup)Vec2)ShaderPrograma  #version 150 core
    in vec2 position;
    in vec2 translation;
    in vec4 colors;
    in float zposition;

    in float rotation;


    out vec4 vertex_colors;

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

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

    void main()
    {
        m_translate[3][0] = translation.x;
        m_translate[3][1] = translation.y;
        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 * vec4(position, zposition, 1.0);
        vertex_colors = colors;
    }
a  #version 150 core
    in vec4 vertex_colors;
    out vec4 final_color;

    void main()
    {
        final_color = vertex_colors;
        // No GL_ALPHA_TEST in core, use shader to discard.
        if(final_color.a < 0.01){
            discard;
        }
    }
returnr   c                 h    t           j        j                            t          dft
          df          S )Nvertexfragment)pygletglcurrent_contextcreate_programvertex_sourcefragment_source     H/home/agentuser/manim-venv/lib/python3.11/site-packages/pyglet/shapes.pyget_default_shaderr#      s1    9$33]H4M5Dj4QS S Sr!   centertuple[float, float]pointanglefloatc                   t          j        |d         | d         z
  |d         | d         z
            }||z   }t          j        ||           }| d         |t          j        |          z  z   | d         |t          j        |          z  z   fS N   r   )mathatan2distcossin)r$   r&   r'   
prev_angle	now_anglers         r"   _rotate_pointr4      s    E!Hvay0%(VAY2FGGJU"I	%  A!9q48I....q	A@S@S<S0SSSr!   polygonSequence[tuple[float, float]]boolc                   d}d}t          |           dz
  }|t          |           dz
  k     r|dz   }| |         d         |d         k    | |         d         |d         k    k    ro|d         | |         d         | |         d         z
  |d         | |         d         z
  z  | |         d         | |         d         z
  z  | |         d         z   k     r| }|}|t          |           dz
  k     |S )zUse raycasting to determine if a point is inside a polygon.

    This function is an example implementation available under MIT License at:
    https://www.algorithms-and-technologies.com/point_in_polygon/python
    Fr   r+   )len)r5   r&   oddijs        r"   _point_in_polygonr=      s    C	AGqA
c'llQ

EQZ]U1X%71:a=58+CDDa AA658gajQRm;ST"1:a=71:a=8: !*Q-	     'C c'llQ

 Jr!         ?p0!tuple[float, float] | list[float]p1p2p3	thickness
prev_miterVec2 | None
prev_scaleetuple[Vec2, Vec2, float, float, float, float, float, float, float, float, float, float, float, float]c                   t          |d         |d         z
  |d         |d         z
                                            }t          |j         |j                  }|}	|dz  x}
}|}|r|r|}|}
n| rt          |d         | d         z
  |d         | d         z
                                            }t          |j         |j                  }t          |j        |j        z   |j        |j        z                                             }	 t	          dt          d|                    |                              }|
t          j        t          j	        |                    z  }
n# t          $ r |dz  }
Y nw xY w|rt          |d         |d         z
  |d         |d         z
                                            }t          |j         |j                  }t          |j        |j        z   |j        |j        z                                             }		 t	          dt          d|                    |	                              }|t          j        t          j	        |                    z  }n# t          $ r |dz  }Y nw xY wt          |
d|z            }
t          |d|z            }|j        |
z  |j        |
z  f}|	j        |z  |	j        |z  f}|d         |d         z   |d         |d         z   f}|d         |d         z   |d         |d         z   f}|d         |d         z
  |d         |d         z
  f}|d         |d         z   |d         |d         z   f}|d         |d         z
  |d         |d         z
  f}|d         |d         z
  |d         |d         z
  f}|	||d         |d         |d         |d         |d         |d         |d         |d         |d         |d         |d         |d         fS )a  Computes a line segment between the points p1 and p2.

    If points p0 or p3 are supplied then the segment p1->p2 will have the correct "miter" angle
    for each end respectively.  This returns computed miter and scale values which can be supplied
    to the next call of the method for a minor performance improvement.  If they are not supplied
    then they will be computed.

    Args:
        p0:
            The "previous" point for the segment p1->p2 which is used to compute the "miter"
            angle of the start of the segment.  If None is supplied then the start of the line
            is 90 degrees to the segment p1->p2.
        p1:
            The origin of the segment p1->p2.
        p2:
            The end of the segment p1->p2
        p3:
            The "following" point for the segment p1->p2 which is used to compute the "miter"
            angle to the end of the segment.  If None is supplied then the end of the line is
            90 degrees to the segment p1->p2.
        thickness:
            Thickness of the miter.
        prev_miter:
            The miter value to be used.
        prev_scale:
            The scale value to be used.
    r   r+   g       @g      r>   )r   	normalizeyxmaxmindotr,   r0   acosZeroDivisionError)r?   rA   rB   rC   rD   rE   rG   v_np1p2v_normalv_miter2scale1scale2v_miter1v_np0p1v_normal_p0p1rO   v_np2p3v_normal_p2p3miter1_scaled_pmiter2_scaled_pv1v2v3v4v5v6s                             r"   _get_segmentrd      s   > 2a52a5="Q%"Q%-00::<<GWYJ	**H H#o%FV H %j %	 
%r!ur!u}bebem44>>@@giZ33(*4mo
6RSS]]__	%dCW[[%:%:;;<<Cdhty~~666FF  	% 	% 	%_FFF	% 
 
%r!ur!u}bebem44>>@@giZ33(*4mo
6RSS]]__	%dCW[[%:%:;;<<Cdhty~~666FF  	% 	% 	%_FFF	%
 y))Fy))F  zF*HJ,?@OzF*HJ,?@O
Q%/!$
$beoa.@&@	AB
Q%/!$
$beoa.@&@	AB
Q%/!$
$beoa.@&@	AB
Q%/!$
$beoa.@&@	AB
Q%/!$
$beoa.@&@	AB
Q%/!$
$beoa.@&@	ABVRUBqE2a5"Q%A1r!ubQReUWXYUZ\^_`\acefgchjlmnjooos&   AE' 'E98E9AI2 2JJc                  F     e Zd ZdZdd fdZddZddZddZddZ xZ	S )_ShapeGroupzShared Shape rendering Group.

    The group is automatically coalesced with other shape groups
    sharing the same parent group and blend parameters.
    N	blend_srcint
blend_destprogramr   parentGroup | Noner   Nonec                v    t                                          |           || _        || _        || _        dS )a  Create a Shape group.

        The group is created internally. Usually you do not
        need to explicitly create it.

        Args:
            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:
                The ShaderProgram to use.
            parent:
                Optional parent group.
        )rk   N)super__init__rj   rg   ri   )selfrg   ri   rj   rk   	__class__s        r"   rp   z_ShapeGroup.__init__  s9      	'''"$r!   c                    | j                                          t          t                     t	          | j        | j                   d S N)rj   bindr   r   r   rg   ri   rq   s    r"   	set_statez_ShapeGroup.set_state  s>    DNDO44444r!   c                `    t          t                     | j                                         d S rt   )r   r   rj   unbindrv   s    r"   unset_statez_ShapeGroup.unset_state  s*    (r!   otherGroup | _ShapeGroupc                    |j         | j         u o?| j        |j        k    o/| j        |j        k    o| j        |j        k    o| j        |j        k    S rt   )rr   rj   rk   rg   ri   )rq   r{   s     r"   __eq__z_ShapeGroup.__eq__#  s\    4>1 4-4u|+4 %/14 5#33		5r!   c                P    t          | j        | j        | j        | j        f          S rt   )hashrj   rk   rg   ri   rv   s    r"   __hash__z_ShapeGroup.__hash__*  s!    T\4;PQQQr!   rt   )
rg   rh   ri   rh   rj   r   rk   rl   r   rm   r   rm   )r{   r|   r   rm   r   rh   )
__name__
__module____qualname____doc__rp   rw   rz   r~   r   __classcell__rr   s   @r"   rf   rf      s         % % % % % % %*5 5 5 5
   5 5 5 5R R R R R R R Rr!   rf   c                     e Zd ZU dZdZdZded<   dZded<   dZded	<   dZ	ded
<   dZ
ded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZeZded<   eZded<   eedddfdWd$ZdXd%ZdYd(ZdZd*ZdXd+ZdXd,ZdXd-ZedXd.            Z e!d[d0            Z"e"j#        d\d2            Z"e!d]d4            Z$e$j#        d^d5            Z$e!d_d6            Z%e%j#        d`d8            Z%dXd9Z&dXd:Z'e!d_d;            Z(e(j#        dad=            Z(e!d_d>            Z)e)j#        dad?            Z)e!d_d@            Z*e*j#        dadA            Z*e!dbdB            Z+e+j#        dcdD            Z+e!d_dE            Z,e,j#        dadF            Z,e!d_dG            Z-e-j#        dadH            Z-e!dbdI            Z.e.j#        dcdJ            Z.e!dddL            Z/e/j#        dedN            Z/e!dfdO            Z0e0j#        dgdP            Z0e!dhdQ            Z1e1j#        didR            Z1e!djdS            Z2e2j#        dkdT            Z2e!dldU            Z3e3j#        dmdV            Z3dS )n	ShapeBaseaI  Base class for all shape objects.

    A number of default shapes are provided in this module. Curves are
    approximated using multiple vertices.

    If you need shapes or functionality not provided in this module,
    you can write your own custom subclass of ``ShapeBase`` by using
    the provided shapes as reference.
       r   r   r           r(   	_rotationTr7   _visible_x_y_z	_anchor_x	_anchor_yNBatch | None_batchz_ShapeGroup | Group | None_groupr   rh   
_num_vertsrl   _user_group
_draw_moder   group_classvertex_countrg   ri   batchgrouprj   ShaderProgram | Noner   rm   c                    || _         || _        || _        || _        || _        |pt                      | _        |                                 | _        | 	                                 dS )a.  Initialize attributes that all Shape object's require.

        Args:
            vertex_count:
                The amount of vertices this Shape object has.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch object.
            group:
                Optional group object.
            program:
                Optional ShaderProgram object.
        N)
r   
_blend_src_blend_destr   r   r#   _programget_shape_groupr   _create_vertex_list)rq   r   rg   ri   r   r   rj   s          r"   rp   zShapeBase.__init__K  sg    0 '#% 7#5#7#7**,,  """""r!   c                X    | j         "| j                                          d | _         d S d S rt   _vertex_listdeleterv   s    r"   __del__zShapeBase.__del__l  s6    ($$&&& $D )(r!   r&   r%   c                :    t          d| j        j                   )z'Test whether a point is inside a shape.z'The `in` operator is not supported for )NotImplementedErrorrr   r   rq   r&   s     r"   __contains__zShapeBase.__contains__q  s    !"eDNLc"e"efffr!   _ShapeGroup | Groupc                Z    |                      | j        | j        | j        | j                  S )a  Creates and returns a group to be used to render the shap[e.

        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   r   r   r   r   rv   s    r"   r   zShapeBase.get_shape_groupu  s)     1A4=RVRbcccr!   c                B    | j         | j        z  | j        j        dd<   dS )a5  Send the new colors for each vertex to the GPU.

        This method must set the contents of `self._vertex_list.colors`
        using a list or tuple that contains the RGBA color components
        for each vertex in the shape. This is usually done by repeating
        `self._rgba` for each vertex.
        N_rgbar   r   colorsrv   s    r"   _update_colorzShapeBase._update_color  s'     '+j4?&B ###r!   c                P    | j         | j        f| j        z  | j        j        d d <   d S rt   )r   r   r   r   translationrv   s    r"   _update_translationzShapeBase._update_translation  s,    ,0GTW+=+O%aaa(((r!   c                     t          d          )a  Build internal vertex list.

        This method must create a vertex list and assign it to
        `self._vertex_list`. It is advisable to use it
        during `__init__` and to then update the vertices accordingly
        with `self._update_vertices`.

        While it is not mandatory to implement it, some properties (
        namely `batch` and `group`) rely on this method to properly
        recreate the vertex list.
        zM_create_vertex_list must be defined in order to use group or batch propertiesr   rv   s    r"   r   zShapeBase._create_vertex_list  s     ""qrrrr!   c                     t          d          )aS  Generate up-to-date vertex positions & send them to the GPU.

        This method must set the contents of `self._vertex_list.vertices`
        using a list or tuple that contains the new vertex coordinates for
        each vertex in the shape. See the `ShapeBase` subclasses in this
        module for examples of how to do this.
        z=_update_vertices must be defined for every ShapeBase subclassr   rv   s    r"   _update_verticeszShapeBase._update_vertices  s     ""abbbr!   tuple[int, int]c                    | j         | j        fS )zThe current blend mode applied to this shape.

        .. note:: Changing this can be an expensive operation as it involves a group creation and transfer.
        )r   r   rv   s    r"   
blend_modezShapeBase.blend_mode  s      000r!   modesc                \   |\  }}|| j         k    r|| j        k    rd S || _         || _        |                                 | _        | j        3| j                            | j        | j        | j        | j                   d S | j                                         | 	                                 d S rt   )
r   r   r   r   r   migrater   r   r   r   )rq   r   srcdsts       r"   r   zShapeBase.blend_mode  s    S$/!!cT-=&=&=F**,,;"K 14?DKQUQ\]]]]]$$&&&$$&&&&&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.
        )r   rv   s    r"   rj   zShapeBase.program       }r!   c                $   | j         |k    rd S || _         |                                 | _        | j        r.| j                            | j        t          | j        |          rd S | j                                         |                                  d S rt   )	r   r   r   r   update_shaderr   r   r   r   )rq   rj   s     r"   rj   zShapeBase.program  s    =G##F**,,K 	))$*;\4;X_``	 F 	  """  """""r!   c                    | j         S )a  Get/set the shape's clockwise rotation in degrees.

        All shapes rotate around their :attr:`.anchor_position`.
        For most shapes, this defaults to both:

        * The shape's first vertex of the shape
        * The lower left corner

        Shapes with a ``radius`` property rotate around the
        point the radius is measured from. This will be either
        their center or the center of the circle they're cut from:

        These shapes rotate around their center:

        * :py:class:`.Circle`
        * :py:class:`.Ellipse`
        * :py:class:`.Star`

        These shapes rotate around the point of their angles:

        * :py:class:`.Arc`
        * :py:class:`.Sector`

        )r   rv   s    r"   rotationzShapeBase.rotation  s    4 ~r!   r   c                H    || _         |f| j        z  | j        j        d d <   d S rt   )r   r   r   r   )rq   r   s     r"   r   zShapeBase.rotation  s,    !)1do(E"111%%%r!   c                    | j                                          | j                            | j                   | j                                          dS )a  Debug method to draw a single shape at its current position.

        .. warning:: Avoid this inefficient method for everyday use!

                     Regular drawing should add shapes to a :py:class:`Batch`
                     and call its :py:meth:`~Batch.draw` method.

        N)r   set_state_recursiver   drawr   unset_state_recursiverv   s    r"   r   zShapeBase.draw  sK     	'')))t///))+++++r!   c                X    | j         "| j                                          d| _         dS dS )a,  Force immediate removal of the shape from video memory.

        You should usually call this whenever you no longer need the shape.
        Otherwise, Python may call the finalizer of the shape instance only
        some time after the shape has fallen out of scope, and the shape's video
        memory will not be freed until the finalizer is eventually called by
        garbage collection.

        Implementing manual garbage collection may satisfy the same concern
        without using the current method, but is a very advanced technique.
        Nr   rv   s    r"   r   zShapeBase.delete  s8     ($$&&& $D )(r!   c                    | j         S )a&  Get/set the X coordinate of the shape's :py:attr:`.position`.

        #. To update both :py:attr:`.x` and :py:attr:`.y`, use
           :attr:`.position` instead.
        #. Shapes may vary slightly in how they use :py:attr:`.position`

        See :py:attr:`.position` to learn more.
        )r   rv   s    r"   rL   zShapeBase.x  s     wr!   valuec                <    || _         |                                  d S rt   )r   r   rq   r   s     r"   rL   zShapeBase.x!  !      """""r!   c                    | j         S )aY  Get/set the Y coordinate of the shape's :py:attr:`.position`.

        This property has the following pitfalls:

        #. To update both :py:attr:`.x` and :py:attr:`.y`, use
           :py:attr:`.position` instead.
        #. Shapes may vary slightly in how they use :py:attr:`.position`

        See :attr:`.position` to learn more.
        )r   rv   s    r"   rK   zShapeBase.y&  s     wr!   c                <    || _         |                                  d S rt   )r   r   r   s     r"   rK   zShapeBase.y4  r   r!   c                    | j         S )a?  Get/set the Z coordinate of the shape.

        You must enable depth testing for this to have any effect.
        For example: create a custom parent :py:class:`~pyglet.graphics.Group`
        that enables and disables depth testing, and use that with all of
        your shapes that will have non-0 Z values.
        )r   rv   s    r"   zzShapeBase.z9  s     wr!   c                >    || _         |f| j        z  | j        _        d S rt   )r   r   r   	zpositionr   s     r"   r   zShapeBase.zD  s#    ',h&@###r!   c                    | j         | j        fS )a<  Get/set the ``(x, y)`` coordinates of the shape.

        .. tip:: This is more efficient than setting :py:attr:`.x`
                 and :py:attr:`.y` separately!

        All shapes default to rotating around their position. However,
        the way they do so varies.

        Shapes with a ``radius`` property will use this as their
        center:

        * :py:class:`.Circle`
        * :py:class:`.Ellipse`
        * :py:class:`.Arc`
        * :py:class:`.Sector`
        * :py:class:`.Star`

        Others default to using it as their lower left corner.
        )r   r   rv   s    r"   positionzShapeBase.positionI  s    * wr!   valuesc                L    |\  | _         | _        |                                  d S rt   )r   r   r   rq   r   s     r"   r   zShapeBase.position`  s(    !  """""r!   c                    | j         S )zGet/set the X coordinate of the anchor point.

        If you need to set both this and :py:attr:`.anchor_x`, use
        :py:attr:`.anchor_position` instead.
        )r   rv   s    r"   anchor_xzShapeBase.anchor_xe       ~r!   c                <    || _         |                                  d S rt   )r   r   r   s     r"   r   zShapeBase.anchor_xn  !    r!   c                    | j         S )zGet/set the Y coordinate of the anchor point.

        If you need to set both this and :py:attr:`.anchor_x`, use
        :py:attr:`.anchor_position` instead.
        )r   rv   s    r"   anchor_yzShapeBase.anchor_ys  r   r!   c                <    || _         |                                  d S rt   )r   r   r   s     r"   r   zShapeBase.anchor_y|  r   r!   c                    | j         | j        fS )a6  Get/set the anchor's ``(x, y)`` offset from :py:attr:`.position`.

        This defines the point a shape rotates around. By default, it is
        ``(0.0, 0.0)``. However:

        * Its behavior may vary between shape classes.
        * On many shapes, you can set the anchor or its components
          (:py:attr:`.anchor_x` and :attr:`.anchor_y`) to custom values.

        Since all anchor updates recalculate a shape's vertices on the
        CPU, this property is faster than updating :py:attr:`.anchor_x` and
        :py:attr:`.anchor_y` separately.
        )r   r   rv   s    r"   anchor_positionzShapeBase.anchor_position  s     ~t~--r!   c                L    |\  | _         | _        |                                  d S rt   )r   r   r   r   s     r"   r   zShapeBase.anchor_position  s(    )/&r!   tuple[int, int, int, int]c                    | j         S )a  Get/set the shape's color.

        The color may set to:

        - An RGBA tuple of integers ``(red, green, blue, alpha)``
        - An RGB tuple of integers ``(red, green, blue)``

        If an RGB color is set, the current alpha will be preserved.
        Otherwise, the new alpha value will be used for the shape. Each
        color component must be in the range 0 (dark) to 255 (saturated).
        r   rv   s    r"   colorzShapeBase.color  s     zr!   0tuple[int, int, int, int] | tuple[int, int, int]c                    |^}}}}|r||||d         f| _         n|||| j         d         f| _         |                                  d S Nr      r   r   )rq   r   r3   gbas         r"   r   zShapeBase.color  s\    
 1a! 	0Aq!A$DJJAq$*Q-/DJr!   c                    | j         d         S )a  Get/set the blend opacity of the shape.

        .. tip:: To toggle visibility on/off, :py:attr:`.visible` may be
                 more efficient!

        Opacity is implemented as the alpha component of a shape's
        :py:attr:`.color`. When part of a group with a default blend
        mode of ``(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)``, opacities
        below ``255`` draw with fractional opacity over the background:

        .. list-table:: Example Values & Effects
           :header-rows: 1

           * - Opacity
             - Effect

           * - ``255`` (Default)
             - Shape is fully opaque

           * - ``128``
             - Shape looks translucent

           * - ``0``
             - Invisible

        r   r   rv   s    r"   opacityzShapeBase.opacity  s    8 z!}r!   c                `    g | j         d d         |R | _         |                                  d S )Nr   r   r   s     r"   r   zShapeBase.opacity  s8    -tz"1"~-u--
r!   c                    | j         S )zhGet/set whether the shape will be drawn at all.

        For absolute showing / hiding, this is
        )r   rv   s    r"   visiblezShapeBase.visible  r   r!   c                <    || _         |                                  d S rt   )r   r   r   s     r"   r   zShapeBase.visible  s!    r!   c                    | j         S )a-  Get/set the shape's :class:`Group`.

        You can migrate a shape from one group to another by setting
        this property. Note that it can be an expensive (slow) operation.

        If :py:attr:`.batch` isn't ``None``, setting this property will
        also trigger a batch migration.
        )r   rv   s    r"   r   zShapeBase.group  s     r!   c                    | j         |k    rd S || _         |                                 | _        | j        r3| j                            | j        | j        | j        | j                   d S d S rt   )r   r   r   r   r   r   r   )rq   r   s     r"   r   zShapeBase.group  st    u$$F **,,; 	^K 14?DKQUQ\]]]]]	^ 	^r!   c                    | j         S )aO  Get/set the :py:class:`Batch` for this shape.

        .. warning:: Setting this to ``None`` currently breaks things!

                     Known issues include :py:attr:`.group` breaking.

        You can migrate a shape from one batch to another by setting
        this property, but it can be an expensive (slow) operation.
        )r   rv   s    r"   r   zShapeBase.batch  s     {r!   c                   | j         |k    rd S |<| j         5| j                             | j        | j        | j        |           || _         d S | j                                         || _         |                                  d S rt   )r   r   r   r   r   r   r   )rq   r   s     r"   r   zShapeBase.batch  s    ;%F!8K 14?DKQVWWWDKKK$$&&&DK$$&&&&&r!   )r   rh   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r   r&   r%   r   r7   )r   r   )r   r   )r   r   r   rm   r   r   )rj   r   r   rm   r   r(   )r   r(   r   rm   r   r(   r   rm   )r   r%   )r   r%   r   rm   r   r   r   r   r   rm   r   r   rh   r   rm   )r   r7   )r   r7   r   rm   )r   rl   )r   r   r   rm   )r   r   )r   r   r   rm   )4r   r   r   r   r   r   __annotations__r   r   r   r   r   r   r   r   r   r   r   r   r   rf   r   r   r   rp   r   r   r   r   r   r   r   r   propertyr   setterrj   r   r   r   rL   rK   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r   r   .  s          !EIHBOOOOBOOOOBOOOOIIF)-F----J $K$$$$L"J""""$K$$$$ #/#9'+'+15# # # # #B% % % %
g g g g
d 
d 
d 
dC C C CP P P Ps s s s c c c ^c 1 1 1 X1 ' ' ' '    X ^# # # ^#    X6 _F F F _F, , , ,% % % %  	 	 	 X	 X# # # X#    X X# # # X#    X XA A A XA       X , _# # # _#    X _      _     X _      _  . . . X.             X \   \    X: ^   ^    X ^      ^  	  	  	  X	  \^ ^ ^ \^ 
 
 
 X
 \
' 
' 
' \
' 
' 
'r!   r   c                  8    e Zd Zddddddeedddfd- fdZd.d Zd/d"Zd.d#Ze	d0d$            Z
e
j        d1d&            Z
e	d0d'            Zej        d2d(            Ze	d0d)            Zej        d1d*            Ze	d0d+            Zej        d3d,            Z xZS )4ArcN     v@r   Fr>   r   rL   r(   rK   radiussegments
int | Noner'   start_angleclosedr7   rD   r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                   || _         || _        d| _        || _        |pt	          dt          |dz                      | _        |	^}}}}||||r|d         ndf| _        || _        || _	        || _
        t          t          j        | j	        z
            dk    r|nd| _        d| _        t!                                          | j        dz  | j        rdndz   |
||||           d	S )
aw  Create an Arc.

        The Arc's anchor point (x, y) defaults to its center.

        Args:
            x:
                X coordinate of the circle.
            y:
                Y coordinate of the circle.
            radius:
                The desired radius.
            segments:
                You can optionally specify how many distinct line segments
                the arc should be made from. If not specified it will be
                automatically calculated using the formula:
                ``max(14, int(radius / 1.25))``.
            angle:
                The angle of the arc, in degrees. Defaults to 360.0, which is
                a full circle.
            start_angle:
                The start angle of the arc, in degrees. Defaults to 0.
            closed:
                If ``True``, the ends of the arc will be connected with a line.
                defaults to ``False``.
            thickness:
                The desired thickness or width of the line used for the arc.
            color:
                The RGB or RGBA color of the arc, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r            ?r   r   &.>F   N)r   r   r   _radiusrM   rh   	_segmentsr   
_thickness_angle_start_angleabsr,   tau_closedr   ro   rp   )rq   rL   rK   r  r  r'   r  r  rD   r   rg   ri   r   r   rj   r3   r   r   r   rr   s                      r"   rp   zArc.__init__  s    r !@SS$-?-?%@%@ 1a!1a0addS0
#'!$TX%;!<!<t!C!CvvNQt|":!!;z5%	
 	
 	
 	
 	
r!   c                   | j                             | j        | j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S NfBnr   r   r   r   r   vertex_listr   r   r   r   _get_verticesr   r   r   r   r   rv   s    r"   r   zArc._create_vertex_listf       M55OT_dk4;4--//0$*t67tw04?BCDN,t>? 6 A Ar!   Sequence[float]c           
     @  	
 | j         s
d| j        z  S | j         | j         | j        	t          j        | j                  | j        z  
t          j        | j	        | j
        z
            	
fdt          | j        dz             D             }g }d }d }t          t          |          dz
            D ]}d }d }|dk    r||dz
           }n=| j        r	|d         }n-t          | j        t
          j        z
            dk    r|d         }|dz   t          |          k     r||dz            }n=| j        r	|d         }n-t          | j        t
          j        z
            dk    r|d         }t!          |||         ||dz            || j        ||          ^}}}|                    |           | j        red }d }t          |          dk    r|d         }|d         }t!          ||d         |d         || j        ||          ^}}}|                    |           |S )	Nr   r   c           	         g | ]B}t          j        |z  z             z  z   t          j        |z  z             z  z   fCS r    r,   r/   r0   .0r;   r3   segment_radiansstart_radiansrL   rK   s     r"   
<listcomp>z%Arc._get_vertices.<locals>.<listcomp>y  t     r r rRS DHa/&9]%JKKKLDHa/&9]%JKKKLN r r rr!   r+   r   r     )r   r   r   r   r  r,   radiansr  r  r  r   ranger9   r!  r  r   rd   r  extend)rq   pointsverticesrE   rG   r;   
prev_point
next_pointsegmentr3   r2  r3  rL   rK   s            @@@@@r"   r)  zArc._get_verticesn  s   } 	,DO++^O^OL,t{33dnDT%6%GHHr r r r r r r rW\]a]kno]oWpWpr r r 

s6{{Q'' 	% 	%AJJ1uu#AE]

 (#BZ

T[48+,,44#BZ
1us6{{""#AE]

 '#AY

T[48+,,44#AY
/;Jq	SYZ[^_Z_S`bl<@OZYc0e 0e,J
WOOG$$$$< 	%JJ6{{Q#BZ
#AY
/;Jr
TZ[\T]_i<@OZYc0e 0e,J
WOOG$$$r!   c                L    |                                  | j        j        d d <   d S rt   r)  r   r   rv   s    r"   r   zArc._update_vertices  (    (,(:(:(<(<"111%%%r!   c                    | j         S )zGet/set the radius of the arc.r  rv   s    r"   r  z
Arc.radius       |r!   r   c                <    || _         |                                  d S rt   r  r   r   s     r"   r  z
Arc.radius  !    r!   c                    | j         S )z!Get/set the thickness of the Arc.r  rv   s    r"   rD   zArc.thickness       r!   c                <    || _         |                                  d S rt   r  r   rq   rD   s     r"   rD   zArc.thickness  !    #r!   c                    | j         S )z!The angle of the arc, in degrees.r  rv   s    r"   r'   z	Arc.angle       {r!   c                <    || _         |                                  d S rt   r  r   r   s     r"   r'   z	Arc.angle  !    r!   c                    | j         S )z'The start angle of the arc, in degrees.r  rv   s    r"   r  zArc.start_angle         r!   c                <    || _         |                                  d S rt   r  r   rq   r'   s     r"   r  zArc.start_angle  "    !r!   )rL   r(   rK   r(   r  r(   r  r  r'   r(   r  r(   r  r7   rD   r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r   r   r+  r  r  rD   r(   r   rm   r'   r(   r   rm   )r   r   r   r   r   rp   r   r)  r   r  r  r  rD   r'   r  r   r   s   @r"   r  r    s        $( !$ "FZ)4"&"&,0N
 N
 N
 N
 N
 N
 N
`A A A A1 1 1 1f= = = =    X ]      ]     X            X \      \  ! ! ! X!                r!   r  c            
          e Zd Zddddeedddd	d( fdZd)dZd*dZd+dZd*dZ	e
d,d!            Zej        d-d#            Ze
d.d$            Zej        d/d%            Ze
d.d&            Zej        d0d'            Z xZS )1BezierCurver>   d   r   N)	tr  rD   r   rg   ri   r   r   rj   r<  r%   rd  r(   r  rh   rD   r   r   rg   ri   r   r   r   rl   rj   r   r   rm   c       	            t          |
          | _        | j        d         \  | _        | _        || _        || _        || _        |^}}}}||||r|d         ndf| _        t                      	                    | j        dz  |||||	           dS )u2  Create a Bézier curve.

        The curve's anchor point (x, y) defaults to its first control point.

        Args:
            points:
                Control points of the curve. Points can be specified as multiple
                lists or tuples of point pairs. Ex. (0,0), (2,3), (1,9)
            t:
                Draw `100*t` percent of the curve. 0.5 means the curve
                is half drawn and 1.0 means draw the whole curve.
            segments:
                You can optionally specify how many line segments the
                curve should be made from.
            thickness:
                The desired thickness or width of the line used for the curve.
            color:
                The RGB or RGBA color of the curve, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r  N)
list_pointsr   r   _tr  r  r   ro   rp   )rq   rd  r  rD   r   rg   ri   r   r   rj   r<  r3   r   r   r   rr   s                  r"   rp   zBezierCurve.__init__  s    X F||<?!#1a!1a0addS0
NQz5%	
 	
 	
 	
 	
r!   list[float]c                D   t          | j                  dz
  }ddg}t          |dz             D ]q}t          j        ||          d|z
  ||z
  z  z  ||z  z  }|dxx         || j        |         d         z  z  cc<   |dxx         || j        |         d         z  z  cc<   r|S r*   )r9   rg  r:  r,   comb)rq   rd  npr;   ms         r"   _make_curvezBezierCurve._make_curve  s    !Fq1u 	+ 	+A	!Q1q5a!e"44qAv=AaDDDAQ***DDDaDDDAQ***DDDDr!   c                   | j                             | j        | j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r#  r'  rv   s    r"   r   zBezierCurve._create_vertex_list  r*  r!   r+  c           
     V   
  j         s
d j        z  S  j          j        z
   j          j        z
   fdt           j        dz             D             }|d         \  

 j        z  
 j        z  
fd|D             }g }d }d }t          t          |          dz
            D ]y}d }d }|dk    r||dz
           }|dz   t          |          k     r||dz            }t          |||         ||dz            | j
        ||          ^}}}	|                    |	           z|S )Nr-  c                    g | ]^}                     j        |z  j        z            d          z                        j        |z  j        z            d         z   f_S )r   r+   )ro  rh  r  )r1  rd  rq   rL   rK   s     r"   r4  z-BezierCurve._get_vertices.<locals>.<listcomp>!  s     n n nNO t''!dn(DEEaHHt''!dn(DEEaHHJ n n nr!   r+   r   c                *    g | ]\  }}|z
  |z
  gS r    r    r1  rL   rK   trans_xtrans_ys      r"   r4  z-BezierCurve._get_vertices.<locals>.<listcomp>&  s*    @@@A1w;G,@@@r!   r8  )r   r   r   r   r   r   r:  r  r9   rd   r  r;  )rq   r<  coordsr=  rE   rG   r;   r>  r?  r@  ru  rv  rL   rK   s   `         @@@@r"   r)  zBezierCurve._get_vertices  s   } 	,DO++^Odg%^Odg%n n n n n nSXY]YgjkYkSlSln n n!!94>!4>!@@@@@@@@ 

s6{{Q'' 	% 	%AJJ1uu#AE]
1us6{{""#AE]
/;Jq	SYZ[^_Z_S`bl<@OZYc0e 0e,J
WOOG$$$$r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zBezierCurve._update_vertices;  rC  r!   list[tuple[float, float]]c                    | j         S )u0   Get/set the control points of the Bézier curve.)rg  rv   s    r"   r<  zBezierCurve.points>  rF  r!   r   c                <    || _         |                                  d S rt   )rg  r   r   s     r"   r<  zBezierCurve.pointsC  rI  r!   c                    | j         S )z8Get/set the t in ``100*t`` percent of the curve to draw.)rh  rv   s    r"   rd  zBezierCurve.tH       wr!   c                <    || _         |                                  d S rt   )rh  r   r   s     r"   rd  zBezierCurve.tM  !    r!   c                    | j         S )u1   Get/set the line thickness for the Bézier curve.rK  rv   s    r"   rD   zBezierCurve.thicknessR  rL  r!   c                <    || _         |                                  d S rt   rN  rO  s     r"   rD   zBezierCurve.thicknessW  rP  r!   )r<  r%   rd  r(   r  rh   rD   rh   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   )rd  r(   r   ri  r   r^  )r   ry  )r   ry  r   rm   r  r  r_  )r   r   r   r   r   rp   ro  r   r)  r   r  r<  r  rd  rD   r   r   s   @r"   rb  rb    s       
  FZ)4"&"&,07
 7
 7
 7
 7
 7
 7
 7
r   A A A A       D= = = =    X ]      ]     X X      X     X                r!   rb  c                       e Zd Zddeedddfd" fdZd#dZd$dZd%dZd$dZ	e
d&d            Zej        d'd!            Z xZS )(CircleNr   rL   r(   rK   r  r  r  r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                    || _         || _        d| _        || _        |pt	          dt          |dz                      | _        |^}}}}||||r|d         ndf| _        t                      	                    | j        dz  ||||	|
           dS )a  Create a circle.

        The circle's anchor point (x, y) defaults to the center of the circle.

        Args:
            x:
                X coordinate of the circle.
            y:
                Y coordinate of the circle.
            radius:
                The desired radius.
            segments:
                You can optionally specify how many distinct triangles
                the circle should be made from. If not specified it will
                be automatically calculated using the formula:
                `max(14, int(radius / 1.25))`.
            color:
                The RGB or RGBA color of the circle, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r  r  r   r   r   N)
r   r   r   r  rM   rh   r  r   ro   rp   )rq   rL   rK   r  r  r   rg   ri   r   r   rj   r3   r   r   r   rr   s                  r"   rp   zCircle.__init___  s    V !@SS$-?-?%@%@1a!1a0addS0
NQz5%	
 	
 	
 	
 	
r!   r&   r%   r7   c                    t          |          dk    sJ t          j        | j        | j        z
  | j        | j        z
  f|          | j        k     S Nr8  )r9   r,   r.   r   r   r   r   r  r   s     r"   r   zCircle.__contains__  sG    5zzQy$'DN2DGdn4LMuUUX\Xdddr!   c                   | j                             | j        dz  | j        | j        | j        d|                                 fd| j        | j        z  fd| j	        | j
        f| j        z  fd| j        f| j        z  f          | _        d S Nr   r$  r%  r&  r   r(  r  r   r   r   r)  r   r   r   r   r   r   rv   s    r"   r   zCircle._create_vertex_list       M55NQdk4--//0$*t67tw04?BCDN,t>? 6 A Ar!   r+  c                N  	 | j         s
d| j        z  S | j         | j         	| j        t
          j        dz  | j        z  	fdt          | j                  D             }g }t          |          D ],\  }}	g||dz
           |R }|
                    |           -|S )Nr-  r8  c           	         g | ]<}t          j        |z            z  z   t          j        |z            z  z   f=S r    r/  )r1  r;   r3   tau_segsrL   rK   s     r"   r4  z(Circle._get_vertices.<locals>.<listcomp>  sg     U U U9: DHQ\2223DHQ\22235 U U Ur!   r+   )r   r   r   r   r  r,   pir  r:  	enumerater;  )
rq   r<  r=  r;   r&   triangler3   r  rL   rK   s
         @@@@r"   r)  zCircle._get_vertices  s    } 	,DO++^O^OL7Q;/U U U U U U U>CDN>S>SU U U !&)) 	& 	&HAu!3fQUm3e33HOOH%%%%r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zCircle._update_vertices  rC  r!   c                    | j         S )zGets/set radius of the circle.rE  rv   s    r"   r  zCircle.radius  rF  r!   r   c                <    || _         |                                  d S rt   rH  r   s     r"   r  zCircle.radius  rI  r!   )rL   r(   rK   r(   r  r(   r  r  r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  r  r  )r   r   r   r   r   rp   r   r   r)  r   r  r  r  r   r   s   @r"   r  r  ]  s         $(FZ)4"&"&,06
 6
 6
 6
 6
 6
 6
pe e e eA A A A   *= = = =    X ]      ]         r!   r  c                       e Zd Zddeedddfd% fdZd&dZd'dZd(dZd'dZ	e
d)d             Zej        d*d"            Ze
d)d#            Zej        d*d$            Z xZS )+EllipseNr   rL   r(   rK   r   r   r  r  r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                <   || _         || _        d| _        || _        || _        |^}}}}||||r|d         ndf| _        d| _        |pt          t          ||          dz            | _	        t                                          | j	        dz  |||	|
|           dS )a  Create an ellipse.

        The ellipse's anchor point ``(x, y)`` defaults to the center of
        the ellipse.

        Args:
            x:
                X coordinate of the ellipse.
            y:
                Y coordinate of the ellipse.
            a:
                Semi-major axes of the ellipse.
            b:
                Semi-minor axes of the ellipse.
            segments:
                You can optionally specify how many distinct line segments
                the ellipse should be made from. If not specified it will be
                automatically calculated using the formula:
                ``int(max(a, b) / 1.25)``.
            color:
                The RGB or RGBA color of the ellipse, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r  r   N)r   r   r   _a_br   r   rh   rM   r  ro   rp   )rq   rL   rK   r   r   r  r   rg   ri   r   r   rj   color_rcolor_gcolor_bcolor_arr   s                   r"   rp   zEllipse.__init__  s    \  /4+'Ggwg0N

3N
!:SQT)9%:%:NQz5%	
 	
 	
 	
 	
r!   r&   r%   r7   c                l   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }| j        | j        z  |d         z  |d         f}| j        | j        z  | j        | j	        z
  z  | j        | j
        z
  f}t	          j        ||          | j        k     S Nr8  r   r+   )r9   r4   r   r   r,   r9  r   r  r  r   r   r.   )rq   r&   shape_centers      r"   r   zEllipse.__contains__	  s    5zzQtw0%dn9U9UVV 47"U1X-uQx8$')TWt~-EFRVR`H`ayu--77r!   c                   | j                             | j        dz  | j        | j        | j        d|                                 fd| j        | j        z  fd| j	        | j
        f| j        z  fd| j        f| j        z  f          | _        d S r  r  rv   s    r"   r   zEllipse._create_vertex_list  r  r!   r+  c                @     j         s
d j        z  S  j          j         t          j        dz   j        z   fdt           j                  D             }g }t          |          D ],\  }}g||dz
           |R }|	                    |           -|S )Nr-  r8  c           	         g | ]F}j         t          j        |z            z  z   j        t          j        |z            z  z   fGS r    )r  r,   r/   r  r0   )r1  r;   rq   r  rL   rK   s     r"   r4  z)Ellipse._get_vertices.<locals>.<listcomp>#  sk     Y Y Y=> tw!h,!7!777tw!h,!7!7779 Y Y Yr!   r+   )
r   r   r   r   r,   r  r  r:  r  r;  )	rq   r<  r=  r;   r&   r  r  rL   rK   s	   `     @@@r"   r)  zEllipse._get_vertices  s    } 	,DO++^O^O7Q;/Y Y Y Y Y Y YBGBWBWY Y Y !&)) 	& 	&HAu!3fQUm3e33HOOH%%%%r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zEllipse._update_vertices.  rC  r!   c                    | j         S )z+Get/set the semi-major axes of the ellipse.)r  rv   s    r"   r   z	Ellipse.a1  r}  r!   r   c                <    || _         |                                  d S rt   )r  r   r   s     r"   r   z	Ellipse.a6  r  r!   c                    | j         S )z+Get/set the semi-minor axes of the ellipse.)r  rv   s    r"   r   z	Ellipse.b;  r}  r!   c                <    || _         |                                  d S rt   )r  r   r   s     r"   r   z	Ellipse.b@  r  r!   )rL   r(   rK   r(   r   r(   r   r(   r  r  r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  r  r  )r   r   r   r   r   rp   r   r   r)  r   r  r   r  r   r   r   s   @r"   r  r    s2        $(FZ)4"&"&,0?
 ?
 ?
 ?
 ?
 ?
 ?
B8 8 8 8A A A A   (= = = =    X X      X     X X      X         r!   r  c            	          e Zd Zddddeedddf	d* fdZd+dZd,dZd-d!Zd,d"Z	e
d.d#            Zej        d/d%            Ze
d.d&            Zej        d0d'            Ze
d.d(            Zej        d/d)            Z xZS )1SectorNr  r   r   rL   r(   rK   r  r  r  r'   r  r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                J   || _         || _        d| _        || _        |pt	          dt          |dz                      | _        |^}}}}||||r|d         ndf| _        || _        || _	        d| _
        t                                          | j        dz  ||	|
||           dS )a  Create a Sector of a circle.

        By default, ``(x, y)`` is used as:
        * The sector's anchor point
        * The center of the circle the sector is cut from

        Args:
            x:
                X coordinate of the sector.
            y:
                Y coordinate of the sector.
            radius:
                The desired radius.
            segments:
                You can optionally specify how many distinct triangles
                the sector should be made from. If not specified it will
                be automatically calculated using the formula:
                `max(14, int(radius / 1.25))`.
            angle:
                The angle of the sector, in degrees. Defaults to 360,
                which is a full circle.
            start_angle:
                The start angle of the sector, in degrees. Defaults to 0.
            color:
                The RGB or RGBA color of the circle, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r  r  r   r   r   N)r   r   r   r  rM   rh   r  r   r  r  r   ro   rp   )rq   rL   rK   r  r  r'   r  r   rg   ri   r   r   rj   r3   r   r   r   rr   s                    r"   rp   zSector.__init__H  s    h !@SS$-?-?%@%@1a!1a0addS0
'NQz5%	
 	
 	
 	
 	
r!   r&   r%   r7   c                   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }t	          j        | j        | j        z
  | j        | j	        z
  f|          | j
        k    rdS t	          j        t	          j        |d         | j        z
  | j	        z   |d         | j        z
  | j        z                       }|dz  }| j        dz  }|| j        z   dz  }| j        dk    r"||k    r||cxk    o|k    nc S ||k    p||k    S ||k    r||cxk    o|k    nc S ||k    p||k    S )Nr8  Fr+   r   ih  )r9   r4   r   r   r,   r9  r   r.   r   r   r  degreesr-   r  r  )rq   r&   r'   r  	end_angles        r"   r   zSector.__contains__  sn   5zzQtw0%dn9U9UVV9dg.$.0HI5QQTXT```5TZa47(:T^(KUSTXX\X_M_bfbpMpqqrr'#- 4;.#5	;!i''"e8888y88888+Au	/AAK'' E8888[88888	)AUk-AAr!   c                   | j                             | j        | j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r#  r'  rv   s    r"   r   zSector._create_vertex_list  r*  r!   r+  c                  	
 | j         s
d| j        z  S | j         	| j         
| j        t          j        | j                  | j        z  t          j        | j	                  	
fdt          | j        dz             D             }g }t          |dd          d          D ],\  }}	
g||dz
           |R }|                    |           -|S )Nr-  c           	         g | ]B}t          j        |z  z             z  z   t          j        |z  z             z  z   fCS r    r/  r0  s     r"   r4  z(Sector._get_vertices.<locals>.<listcomp>  r5  r!   r+   )start)r   r   r   r   r  r,   r9  r  r  r  r:  r  r;  )rq   r<  r=  r;   r&   r  r3   r2  r3  rL   rK   s         @@@@@r"   r)  zSector._get_vertices  s"   } 	,DO++^O^OL,t{33dnDT%677r r r r r r r rW\]a]kno]oWpWpr r r !&*A666 	& 	&HAu!3fQUm3e33HOOH%%%%r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zSector._update_vertices  rC  r!   c                    | j         S )z$The angle of the sector, in degrees.rR  rv   s    r"   r'   zSector.angle  rS  r!   r   c                <    || _         |                                  d S rt   rU  r   s     r"   r'   zSector.angle  rV  r!   c                    | j         S )z*The start angle of the sector, in degrees.rX  rv   s    r"   r  zSector.start_angle  rY  r!   c                <    || _         |                                  d S rt   r[  r\  s     r"   r  zSector.start_angle  r]  r!   c                    | j         S )zGet/set the radius of the sector.

        By default, this is in screen pixels. Your drawing / GL settings
        may alter how this is drawn.
        rE  rv   s    r"   r  zSector.radius       |r!   c                <    || _         |                                  d S rt   rH  r   s     r"   r  zSector.radius  rI  r!   )rL   r(   rK   r(   r  r(   r  r  r'   r(   r  r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  r  r  r`  )r   r   r   r   r   rp   r   r   r)  r   r  r'   r  r  r  r   r   s   @r"   r  r  F  s        $( !$FZ)4"&"&,0D
 D
 D
 D
 D
 D
 D
LB B B B(A A A A   ,= = = =    X \      \  ! ! ! X!            X ]      ]         r!   r  c                       e Zd Zddeedddfd' fdZd(dZd)dZd*dZd)dZ	e
d+d             Zej        d,d!            Ze
d+d"            Zej        d-d$            Ze
d+d%            Zej        d-d&            Z xZS ).Liner>   r   NrL   r(   rK   x2y2rD   r   r   rg   rh   ri   r   r   r   rl   rj   r   c                    || _         || _        d| _        || _        || _        || _        d| _        |^}}}}||||r|d         ndf| _        t                      	                    d|||	|
|           dS )au  Create a line.

        The line's anchor point defaults to the center of the line's
        thickness on the X axis, and the Y axis.

        Args:
            x:
                The first X coordinate of the line.
            y:
                The first Y coordinate of the line.
            x2:
                The second X coordinate of the line.
            y2:
                The second Y coordinate of the line.
            thickness:
                The desired width of the line.
            color:
                The RGB or RGBA color of the line, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r  N)
r   r   r   _x2_y2r  r   r   ro   rp   )rq   rL   rK   r  r  rD   r   rg   ri   r   r   rj   r3   r   r   r   rr   s                   r"   rp   zLine.__init__  s    T #1a!1a0addS0
9j%HHHHHr!   r&   r%   r   r7   c                   t          |          dk    sJ t          | j        | j        z
  | j        | j        z
            }t          | j        | j        z
  | j        | j        z
            }t          |d         | j        z
  | j        z
  |d         | j        z
  | j        z             }t          |d         | j        z
  | j        z
  |d         | j        z
  | j        z             }|                    |          |                    |          z  dk     rdS |d         | j        z   |d         | j        z
  }}| j        | j        | j        | j        f\  }}	}
}t          ||	z  ||
z  z   ||z  z   |
|	z  z
  ||z  z
  ||z  z
            }|t          j        | j        | j        f| j        | j        f          z  }|| j        dz  k     S )Nr8  r   r+   F)r9   r   r  r   r  r   r   r   rO   r  r,   r.   r  )rq   r&   vec_abvec_bavec_apvec_bpr   r   x1y1r  r  double_areahs                 r"   r   zLine.__contains__   s   5zzQdh($(TW*<==dg($'DH*<==eAh(4>958dg;MPTP^;^__eAh)DN:E!Htx<ORVR`<`aa::f

6 2 22Q665Qx$.(%(T^*C1$'48TX=BB !b&1r6/BG3b2g=BFROPP$)TWdg$6488LMMM4?Q&&&r!   rm   c                   | j                             d| j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S Nr  r$  r%  r&  r   r(  r   r   r   r)  r   r   r   r   r   r   rv   s    r"   r   zLine._create_vertex_list1       M55tT[4--//0$*t67tw04?BCDN,t>? 6 A Ar!   r+  c                |   | j         s
d| j        z  S d}| j         dz  }|t          j        | j        | j        z
  | j        | j        z
            z   }|| j        z   }t          j	        | j        | j        z
  | j        | j        z
            }t          j
        |          }t          j        |          }| j        }| j        }	||z  ||z  z
  |z
  }
||z  ||z  z   |	z
  }||z  ||z  z
  |z
  }||z  ||z  z   |	z
  }||z  ||z  z
  |z
  }||z  ||z  z   |	z
  }||z  ||z  z
  |z
  }||z  ||z  z   |	z
  }|
||||||
|||||fS )Nr-  r   r8  )r   r   r  r,   hypotr  r   r  r   r-   r/   r0   r   r   )rq   r  r  r  r  r3   crsrr   r   axaybxbycxcydxdys                     r"   r)  zLine._get_vertices9  s   } 	,DO++o!$*TX/DG1CDDD$/!Jtx$')48dg+=>>Xa[[Xa[[>>"WrBw)"WrBw)"WrBw)"WrBw)"WrBw)"WrBw)"WrBw)"WrBw)2r2r2r2r2r2==r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zLine._update_verticesR  rC  r!   c                    | j         S )zThe thickness of the line.rK  rv   s    r"   rD   zLine.thicknessU  rL  r!   c                <    || _         |                                  d S rt   rN  rO  s     r"   rD   zLine.thicknessZ  rP  r!   c                    | j         S )z)Get/set the 2nd X coordinate of the line.)r  rv   s    r"   r  zLine.x2_       xr!   r   c                <    || _         |                                  d S rt   r  r   r   s     r"   r  zLine.x2d  !    r!   c                    | j         S )z)Get/set the 2nd Y coordinate of the line.)r  rv   s    r"   r  zLine.y2i  r  r!   c                <    || _         |                                  d S rt   r  r   r   s     r"   r  zLine.y2n  r  r!   )rL   r(   rK   r(   r  r(   r  r(   rD   r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r  r   r^  r  r_  r  )r   r   r   r   r   rp   r   r   r)  r   r  rD   r  r  r  r   r   s   @r"   r  r    s}       
  #FZ)4"&"&,06I 6I 6I 6I 6I 6I 6Ip' ' ' '"A A A A> > > >2= = = =    X            X Y      Y     X Y      Y         r!   r  c                       e Zd Zdeedddfd# fdZd$dZd%dZd&dZd%dZ	e
d'd            Zej        d(d             Ze
d'd!            Zej        d(d"            Z xZS ))	Rectangler   NrL   r(   rK   widthheightr   r   rg   rh   ri   r   r   r   rl   rj   r   c                    || _         || _        d| _        || _        || _        d| _        |^}}}}||||r|d         ndf| _        t                                          d||||	|
           dS )a1  Create a rectangle or square.

        The rectangle's anchor point defaults to the ``(x, y)``
        coordinates, which are at the bottom left.

        Args:
            x:
                The X coordinate of the rectangle.
            y:
                The Y coordinate of the rectangle.
            width:
                The width of the rectangle.
            height:
                The height of the rectangle.
            color:
                The RGB or RGBA color of the circle, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r  N)	r   r   r   _width_heightr   r   ro   rp   )rq   rL   rK   r  r  r   rg   ri   r   r   rj   r3   r   r   r   rr   s                  r"   rp   zRectangle.__init__v  s    P 1a!1a0addS0
Iz5%IIIIIr!   r&   r%   r   r7   c                H   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }| j        | j        z
  | j        | j        z
  }}||d         cxk     o|| j	        z   k     nc o||d         cxk     o|| j
        z   k     nc S r  r9   r4   r   r   r,   r9  r   r   r   r  r  rq   r&   rL   rK   s       r"   r   zRectangle.__contains__      5zzQtw0%dn9U9UVVw'4>)A158----a$+o----Q!eAh2Q2Q2Q2QT\AQ2Q2Q2Q2QQr!   rm   c                   | j                             d| j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r  r  rv   s    r"   r   zRectangle._create_vertex_list  r  r!   r+  c                    | j         s
d| j        z  S | j         }| j         }|| j        z   }|| j        z   }||||||||||||fS Nr-  )r   r   r   r   r  r  )rq   r  r  r  r  s        r"   r)  zRectangle._get_vertices  sc    } 	BDO++.B.Bdk!Bdl"Br2r2r2r2r2rAAr!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zRectangle._update_vertices  rC  r!   c                    | j         S zGet/set width of the rectangle.

        The new left and right of the rectangle will be set relative to
        its :py:attr:`.anchor_x` value.
        r  rv   s    r"   r  zRectangle.width       {r!   r   c                <    || _         |                                  d S rt   r  r   r   s     r"   r  zRectangle.width  rV  r!   c                    | j         S zGet/set the height of the rectangle.

        The bottom and top of the rectangle will be positioned relative
        to its :py:attr:`.anchor_y` value.
        r  rv   s    r"   r  zRectangle.height  r  r!   c                <    || _         |                                  d S rt   r  r   r   s     r"   r  zRectangle.height  rI  r!   )rL   r(   rK   r(   r  r(   r  r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r  r   r^  r  r  )r   r   r   r   r   rp   r   r   r)  r   r  r  r  r  r   r   s   @r"   r  r  t  s@        G[)4"&"&,02J 2J 2J 2J 2J 2J 2JhR R R RA A A A	B 	B 	B 	B= = = =    X \      \     X ]      ]         r!   r  c                  |    e Zd Zdddeedddfd1 fdZd2dZd3dZd3dZd4d!Z	d3d"Z
ed5d#            Zej        d6d%            Zed5d&            Zej        d7d(            Zed5d)            Zej        d7d*            Zed8d,            Zej        d9d.            Zed:d/            Zej        d9d0            Z xZS );BorderedRectangler>   )r   r   r   )rc  rc  rc  NrL   r(   rK   r  r  borderr   r   border_colorrg   rh   ri   r   r   r   rl   rj   r   c                r   || _         || _        d| _        || _        || _        d| _        || _        |^}}}}|^}}}}d}|r#|r!|d         |d         k    rt          d          |r	|d         }n
|r|d         }||||f| _        ||||f| _	        t                                          d||	|
||           dS )aM  Create a bordered rectangle.

        The rectangle's anchor point defaults to the ``(x, y)`` coordinates,
        which are at the bottom left.

        Args:
            x:
                The X coordinate of the rectangle.
            y:
                The Y coordinate of the rectangle.
            width:
                The width of the rectangle.
            height:
                The height of the rectangle.
            border:
                The thickness of the border.
            color:
                The RGB or RGBA fill color of the rectangle, specified
                as a tuple of 3 or 4 ints in the range of 0-255. RGB
                colors will be treated as having an opacity of 255.
            border_color:
                The RGB or RGBA fill color of the border, specified
                as a tuple of 3 or 4 ints in the range of 0-255. RGB
                colors will be treated as having an opacity of 255.

                The alpha values must match if you pass RGBA values to
                both this argument and `border_color`. If they do not,
                a `ValueError` will be raised informing you of the
                ambiguity.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   zUWhen color and border_color are both RGBA values,they must both have the same opacity   N)r   r   r   r  r  r   _border
ValueErrorr   _border_rgbaro   rp   )rq   rL   rK   r  r  r  r   r  rg   ri   r   r   rj   fill_rfill_gfill_bfill_aborder_rborder_gborder_bborder_aalpharr   s                         r"   rp   zBorderedRectangle.__init__  s   h */'2>/(Hx  	 h 	 6!9#;#; D E E E  	 1IEE 	 QKE
 VVU2
$h%?Iz5%IIIIIr!   r&   r%   r   r7   c                H   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }| j        | j        z
  | j        | j        z
  }}||d         cxk     o|| j	        z   k     nc o||d         cxk     o|| j
        z   k     nc S r  r  r  s       r"   r   zBorderedRectangle.__contains__9  r  r!   rm   c                   g d}| j                             d| j        || j        | j        d|                                 fd| j        dz  | j        dz  z   fd| j        | j	        f| j
        z  fd| j        f| j
        z  f	  	        | _        d S )N)r   r+   r8  r   r8  r   r      r   r     r   r   r+      r   r  r  r+   r8  r  r  r8  r  r  r8  r   r  r   r  r  r$  r%  r  r&  )r   vertex_list_indexedr   r   r   r)  r   r  r   r   r   r   r   rq   indicess     r"   r   z%BorderedRectangle._create_vertex_list?  s    lll M==tdk4--//0$*q.4+<q+@@Atw04?BCDN,t>? > A Ar!   c                N    | j         dz  | j        dz  z   | j        j        d d <   d S )Nr  )r   r  r   r   rv   s    r"   r   zBorderedRectangle._update_colorH  s/    &*j1nt7H17L&L ###r!   r+  c                    | j         s
d| j        z  S | j         }| j         }|| j        z   }|| j        z   }| j        }||z   }||z   }||z
  }||z
  }	||||||	||	||||||||fS r  )r   r   r   r   r  r  r  )
rq   bx1by1bx2by2r   ix1iy1ix2iy2s
             r"   r)  zBorderedRectangle._get_verticesK  s    } 	,DO++~o~oDKDL LAgAgAgAgS#sCc3S#sCc38 	8r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   z"BorderedRectangle._update_vertices\  rC  r!   c                    | j         S )zThe border thickness of the bordered rectangle.

        This extends inward from the edge of the rectangle toward the
        center.
        )r  rv   s    r"   r  zBorderedRectangle.border_  r  r!   rD   c                <    || _         |                                  d S rt   )r  r   rO  s     r"   r  zBorderedRectangle.borderh  s!     r!   c                    | j         S )zGet/set width of the bordered rectangle.

        The new left and right of the rectangle will be set relative to
        its :py:attr:`.anchor_x` value.
        r  rv   s    r"   r  zBorderedRectangle.widthm  r  r!   r   c                <    || _         |                                  d S rt   r  r   s     r"   r  zBorderedRectangle.widthv  rV  r!   c                    | j         S )zGet/set the height of the bordered rectangle.

        The bottom and top of the rectangle will be positioned relative
        to its :py:attr:`.anchor_y` value.
        r  rv   s    r"   r  zBorderedRectangle.height{  r  r!   c                <    || _         |                                  d S rt   r  r   s     r"   r  zBorderedRectangle.height  rI  r!   r   c                    | j         S )a  Get/set the bordered rectangle's border color.

        To set the color of the interior fill, see :py:attr:`.color`.

        You can set the border color to either of the following:

        * An RGBA tuple of integers ``(red, green, blue, alpha)``
        * An RGB tuple of integers ``(red, green, blue)``

        Setting the alpha on this property will change the alpha of
        the entire shape, including both the fill and the border.

        Each color component must be in the range 0 (dark) to 255 (saturated).
        )r  rv   s    r"   r  zBorderedRectangle.border_color  s        r!   r   c                    |^}}}}|r	|d         }n| j         d         }||||f| _        g | j         d d         |R | _         |                                  d S r   r   r  r   rq   r   r3   r   r   r   r  s          r"   r  zBorderedRectangle.border_color  su    
 1a! 	"aDEEJqMEq!UN+dj!n+e++
r!   c                    | j         S )a6  Get/set the bordered rectangle's interior fill color.

        To set the color of the border outline, see
        :py:attr:`.border_color`.

        The color may be specified as either of the following:

        * An RGBA tuple of integers ``(red, green, blue, alpha)``
        * An RGB tuple of integers ``(red, green, blue)``

        Setting the alpha through this property will change the alpha
        of the entire shape, including both the fill and the border.

        Each color component must be in the range 0 (dark) to 255
        (saturated).
        r   rv   s    r"   r   zBorderedRectangle.color  s    $ zr!   c                    |^}}}}|r	|d         }n| j         d         }||||f| _         g | j        d d         |R | _        |                                  d S r   r,  r-  s          r"   r   zBorderedRectangle.color  sw    
 1a! 	"aDEEJqME1e^
9T.rr29E99r!   )rL   r(   rK   r(   r  r(   r  r(   r  r(   r   r   r  r   rg   rh   ri   rh   r   r   r   rl   rj   r   r  r   r^  r  r_  r  r  r  )r   r   )r   r   r   r   r   rp   r   r   r   r)  r   r  r  r  r  r  r  r   r   r   s   @r"   r   r     s'       
  FUM\)4"&"&,0RJ RJ RJ RJ RJ RJ RJhR R R RA A A AM M M M8 8 8 8"= = = =    X ]      ]     X \      \     X ]      ]  ! ! ! X!"         X& \   \    r!   r   c                      e Zd Zddeedddfd( fdZd)dZd*dZd Zd+dZ	d*d Z
ed,d!            Zej        d-d#            Zed,d$            Zej        d-d%            Zed,d&            Zej        d.d'            Z xZS )/Boxr>   r   NrL   r(   rK   r  r  rD   r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                    || _         || _        d| _        || _        || _        || _        |^}}}}||||r|d         ndf| _        t                                          d|||	|
|           dS )a  Create an unfilled rectangular shape, with optional thickness.

        The box's anchor point defaults to the ``(x, y)`` coordinates,
        which are placed at the bottom left.
        Changing the thickness of the box will extend the walls inward;
        the outward dimensions will not be affected.

        Args:
            x:
                The X coordinate of the box.
            y:
                The Y coordinate of the box.
            width:
                The width of the box.
            height:
                The height of the box.
            thickness:
                The thickness of the lines that make up the box.
            color:
                The RGB or RGBA color of the box, specified as a tuple
                of 3 or 4 ints in the range of 0-255. RGB colors will
                be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r  N)	r   r   r   r  r  r  r   ro   rp   )rq   rL   rK   r  r  rD   r   rg   ri   r   r   rj   r3   r   r   r   rr   s                   r"   rp   zBox.__init__  s    Z #1a!1a0addS0
Iz5%IIIIIr!   r&   r%   r7   c                H   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }| j        | j        z
  | j        | j        z
  }}||d         cxk     o|| j	        z   k     nc o||d         cxk     o|| j
        z   k     nc S r  r  r  s       r"   r   zBox.__contains__  r  r!   c                   g d}| j                             | j        | j        || j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f	  	        | _        d S )N)r   r+   r8  r   r8  r   r   r  r  r   r  r+   r  r  r  r  r  r  r8  r  r  r8  r  r   r$  r%  r&  )r   r  r   r   r   r   r)  r   r   r   r   r   r  s     r"   r   zBox._create_vertex_list  s    
 [ZZ M==OT_gt{DK4--//0$*t67tw04?BCDN,t>? > A Ar!   c                B    | j         | j        z  | j        j        d d <   d S rt   r   rv   s    r"   r   zBox._update_color  s%    &*j4?&B ###r!   r+  c                    | j         s
d| j        z  S | j        }| j         }| j         }|| j        z   }|| j        z   }|}||z   }||z
  }|}	|}
||z   }||z
  }|}||
|||||||||	|
|	|||fS r  )r   r   r  r   r   r  r  )rq   rd  leftbottomrighttopr  r  x3x4r  r  y3y4s                 r"   r)  zBox._get_vertices"  s    } 	,DO++O.t{"t|#AXQYaZ1W2r2r2r2r2r2r2r2MMr!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zBox._update_vertices7  rC  r!   c                    | j         S )zGet/set the width of the box.

        Setting the width will position the left and right sides
        relative to the box's :py:attr:`.anchor_x` value.
        r  rv   s    r"   r  z	Box.width:  r  r!   r   c                <    || _         |                                  d S rt   r  r   s     r"   r  z	Box.widthC  rV  r!   c                    | j         S )zGet/set the height of the Box.

        Setting the height will set the bottom and top relative to the
        box's :py:attr:`.anchor_y` value.
        r  rv   s    r"   r  z
Box.heightH  r  r!   c                V    t          |          | _        |                                  d S rt   )r(   r  r   r   s     r"   r  z
Box.heightQ  s'    U||r!   c                    | j         S )z&Get/set the line thickness of the Box.rK  rv   s    r"   rD   zBox.thicknessV  rL  r!   c                <    || _         |                                  d S rt   rN  rO  s     r"   rD   zBox.thickness[  rP  r!   )rL   r(   rK   r(   r  r(   r  r(   rD   r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  r  r  r_  )r   r   r   r   r   rp   r   r   r   r)  r   r  r  r  r  rD   r   r   s   @r"   r1  r1    s         #FZ)4"&"&,07J 7J 7J 7J 7J 7J 7JrR R R RA A A AC C CN N N N*= = = =    X \      \     X ]      ]     X                r!   r1  c                      e Zd Zddeedddfd, fdZd-dZd.dZd/dZd0d Z	d1d"Z
d0d#Zed2d$            Zej        d3d&            Zed2d'            Zej        d3d(            Zed4d*            Zej        d5d+            Z xZS )6RoundedRectangleNr   rL   r(   rK   r  r  r  8_RadiusT | tuple[_RadiusT, _RadiusT, _RadiusT, _RadiusT]r  &int | tuple[int, int, int, int] | Noner   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                b   || _         || _        d| _        || _        || _        |                     |           |                     |           d| _        |^}}}}||||r|d         ndf| _        t                      
                    t          | j                  dz   dz  ||	|
||           dS )a  Create a rectangle with rounded corners.

        The rectangle's anchor point defaults to the ``(x, y)``
        coordinates, which are at the bottom left.

        Args:
            x:
                The X coordinate of the rectangle.
            y:
                The Y coordinate of the rectangle.
            width:
                The width of the rectangle.
            height:
                The height of the rectangle.
            radius:
                One or four values to specify the radii used for the rounded corners.
                If one value is given, all corners will use the same value. If four values
                are given, it will specify the radii used for the rounded corners clockwise:
                bottom-left, top-left, top-right, bottom-right. A value can be either a single
                float, or a tuple of two floats to specify different x,y dimensions.
            segments:
                You can optionally specify how many distinct triangles each rounded corner
                should be made from. This can be one int for all corners, or a tuple of
                four ints for each corner, specified clockwise: bottom-left, top-left,
                top-right, bottom-right. If no value is specified, it will automatically
                calculated using the formula: ``max(14, int(radius / 1.25))``.
            color:
                The RGB or RGBA color of the rectangle, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r  r   N)r   r   r   r  r  _set_radius_set_segmentsr   r   ro   rp   sumr  )rq   rL   rK   r  r  r  r  r   rg   ri   r   r   rj   r3   r   r   r   rr   s                    r"   rp   zRoundedRectangle.__init__f  s    l    8$$$1a!1a0addS0
  1$)z5%	
 	
 	
 	
 	
r!   c                   t          |t          t          f          r||ffdz  | _        d S t	          |          dk    r|fdz  | _        d S t	          |          dk    sJ g | _        |D ]j}t          |t          t          f          r| j                            ||f           ;t	          |          dk    sJ | j                            |           kd S )Nr  r8  )
isinstancerh   r(   r  r9   append)rq   r  r   s      r"   rK  zRoundedRectangle._set_radius  s    fsEl++ 	/#V,.2DLLL[[A"9q=DLLLv;;!####DL / /ec5\22 /L''7777u::????L''..../ /r!   c                    |%t          d | j        D                       | _        d S t          |t                    r|fdz  | _        d S t          |          dk    sJ || _        d S )Nc              3  \   K   | ]'\  }}t          t          ||          d z            V  (dS )r  N)rh   rM   )r1  r   r   s      r"   	<genexpr>z1RoundedRectangle._set_segments.<locals>.<genexpr>  s;      "R"RTQ3s1ayy4'7#8#8"R"R"R"R"R"Rr!   r  )tupler  r  rO  rh   r9   )rq   r  s     r"   rL  zRoundedRectangle._set_segments  sq    ""R"RT\"R"R"RRRDNNN#&& 	&&[1_DNNNx==A%%%%%DNNNr!   r&   r%   r7   c                H   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }| j        | j        z
  | j        | j        z
  }}||d         cxk     o|| j	        z   k     nc o||d         cxk     o|| j
        z   k     nc S r  r  r  s       r"   r   zRoundedRectangle.__contains__  r  r!   c                   | j                             | j        | j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r#  r'  rv   s    r"   r   z$RoundedRectangle._create_vertex_list  r*  r!   r+  c           	        | j         s
d| j        z  S | j         }| j         }g }|| j        d         d         z   || j        d         d         z   t
          j        dz  dz  f|| j        d         d         z   || j        z   | j        d         d         z
  t
          j        f|| j        z   | j        d         d         z
  || j        z   | j        d         d         z
  t
          j        dz  f|| j        z   | j        d         d         z
  || j        d         d         z   dfg}t          | j        || j
                  D ]V\  \  \  }t
          j         dz  |z  |                    fdt          |dz             D                        W| j        dz  }| j        dz  }g }t          |          D ],\  }	}
||g||	dz
           |
R }|                    |           -|S )Nr-  r   r+   r   r8  c           	         g | ]B}t          j        |z  z             z  z   t          j        |z  z             z  z   fCS r    r/  )r1  r;   	arc_startarc_xarc_yrxryr  s     r"   r4  z2RoundedRectangle._get_vertices.<locals>.<listcomp>  sr     k k kQR "B!h,2J)K)K$KK!B!h,2J)K)K$KKM k k kr!   )r   r   r   r   r  r,   r  r  r  zipr  r;  r:  r  )rq   rL   rK   r<  arc_positionsr  center_xcenter_yr=  r;   r&   r  rY  rZ  r[  r\  r]  r  s               @@@@@@r"   r)  zRoundedRectangle._get_vertices  s[   } 	,DO++^O^O a##a##TWq[1_6 a##Q 22DG= _t|Aq11Q 22DGaKA _t|Aq11a##Q(
 >A}^b^l=m=m 	l 	l9HR/ueYx!|h.HMM k k k k k k k k kV[\dgh\hViVik k k l l l l ;?<!#!&)) 	& 	&HAuAF1q5MAEAAHOOH%%%%r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   z!RoundedRectangle._update_vertices  rC  r!   c                    | j         S r  r  rv   s    r"   r  zRoundedRectangle.width  r  r!   r   c                <    || _         |                                  d S rt   r  r   s     r"   r  zRoundedRectangle.width	  rV  r!   c                    | j         S r  r  rv   s    r"   r  zRoundedRectangle.height
	  r  r!   c                <    || _         |                                  d S rt   r  r   s     r"   r  zRoundedRectangle.height	  rI  r!   Ytuple[tuple[float, float], tuple[float, float], tuple[float, float], tuple[float, float]]c                    | j         S rt   rE  rv   s    r"   r  zRoundedRectangle.radius	  s
    |r!   c                X    |                      |           |                                  d S rt   )rK  r   r   s     r"   r  zRoundedRectangle.radius	  s.    r!   )rL   r(   rK   r(   r  r(   r  r(   r  rH  r  rI  r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   )r  rH  r   rm   )r  rI  r   rm   r  r   r^  r  r  )r   rg  )r   rH  r   rm   )r   r   r   r   r   rp   rK  rL  r   r   r)  r   r  r  r  r  r  r   r   s   @r"   rG  rG  d  s        @DFZ)4"&"&,0E
 E
 E
 E
 E
 E
 E
N/ / / /& & & &R R R RA A A A$ $ $ $L= = = =    X \      \     X ]      ]     X ]      ]         r!   rG  c                  6    e Zd Zdeedddfd) fdZd*dZd+dZd,dZd+dZ	e
d-d             Zej        d.d"            Ze
d-d#            Zej        d.d$            Ze
d-d%            Zej        d.d&            Ze
d-d'            Zej        d.d(            Z xZS )/Triangler   NrL   r(   rK   r  r  r;  r=  r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                    || _         || _        d| _        || _        || _        || _        || _        d| _        |^}}}}||||r|d         ndf| _        t                      
                    d||	|
||           dS )a  Create a triangle.

        The triangle's anchor point defaults to the first vertex point.

        Args:
            x:
                The first X coordinate of the triangle.
            y:
                The first Y coordinate of the triangle.
            x2:
                The second X coordinate of the triangle.
            y2:
                The second Y coordinate of the triangle.
            x3:
                The third X coordinate of the triangle.
            y3:
                The third Y coordinate of the triangle.
            color:
                The RGB or RGBA color of the triangle, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r   N)r   r   r   r  r  _x3_y3r   r   ro   rp   )rq   rL   rK   r  r  r;  r=  r   rg   ri   r   r   rj   r3   r   r   r   rr   s                    r"   rp   zTriangle.__init__#	  s    X 1a!1a0addS0
Iz5%IIIIIr!   r&   r%   r7   c                    t          |          dk    sJ t          | j        | j        f| j        | j        f| j        | j        f| j        | j        fg|          S r  )r9   r=   r   r   r  r  rm  rn  r   s     r"   r   zTriangle.__contains__]	  s\    5zzQ gtw$(DH!5$(7KdgW[W^M_`  	r!   c                   | j                             d| j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r  r  rv   s    r"   r   zTriangle._create_vertex_listc	  r  r!   r+  c                    | j         s
d| j        z  S | j         }| j         }| j        |z   | j        z
  }| j        |z   | j        z
  }| j        |z   | j        z
  }| j	        |z   | j        z
  }||||||fS r  )
r   r   r   r   r  r   r  r   rm  rn  )rq   r  r  r  r  r;  r=  s          r"   r)  zTriangle._get_verticesk	  s    } 		*DO++.B.BB(BB(BB(BB(Br2r2r))r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zTriangle._update_verticesw	  rC  r!   c                     | j         | j        z   S )z6Get/set the X coordinate of the triangle's 2nd vertex.)r   r  rv   s    r"   r  zTriangle.x2z	       w!!r!   r   c                <    || _         |                                  d S rt   r  r   s     r"   r  zTriangle.x2	  r  r!   c                     | j         | j        z   S )z6Get/set the Y coordinate of the triangle's 2nd vertex.)r   r  rv   s    r"   r  zTriangle.y2	  rt  r!   c                <    || _         |                                  d S rt   r  r   s     r"   r  zTriangle.y2	  r  r!   c                     | j         | j        z   S )z6Get/set the X coordinate of the triangle's 3rd vertex.)r   rm  rv   s    r"   r;  zTriangle.x3	  rt  r!   c                <    || _         |                                  d S rt   )rm  r   r   s     r"   r;  zTriangle.x3	  r  r!   c                     | j         | j        z   S )z1Get/set the Y value of the triangle's 3rd vertex.)r   rn  rv   s    r"   r=  zTriangle.y3	  rt  r!   c                <    || _         |                                  d S rt   )rn  r   r   s     r"   r=  zTriangle.y3	  r  r!   )rL   r(   rK   r(   r  r(   r  r(   r;  r(   r=  r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  r  r  )r   r   r   r   r   rp   r   r   r)  r   r  r  r  r  r;  r=  r   r   s   @r"   rk  rk  "	  s        G[)4"&"&,08J 8J 8J 8J 8J 8J 8Jt   A A A A
* 
* 
* 
*= = = = " " " X" Y      Y  " " " X" Y      Y  " " " X" Y      Y  " " " X" Y      Y         r!   rk  c                       e Zd Zddeedddfd( fdZd)dZd*dZd+dZd*d Z	e
d,d!            Zej        d-d#            Ze
d,d$            Zej        d-d%            Ze
d.d&            Zej        d/d'            Z xZS )0Starr   r   NrL   r(   rK   outer_radiusinner_radius
num_spikesrh   r   r   r   rg   ri   r   r   r   rl   rj   r   r   rm   c                    || _         || _        d| _        || _        || _        || _        || _        |^}}}}||||r|d         ndf| _        t                      	                    |dz  ||	|
||           dS )aC  Create a star.

        The star's anchor point ``(x, y)`` defaults to the on-screen
        center of the star.

        Args:
            x:
                The X coordinate of the star.
            y:
                The Y coordinate of the star.
            outer_radius:
                The desired outer radius of the star.
            inner_radius:
                The desired inner radius of the star.
            num_spikes:
                The desired number of spikes of the star.
            rotation:
                The rotation of the star in degrees. A rotation of 0 degrees
                will result in one spike lining up with the X axis in
                positive direction.
            color:
                The RGB or RGBA color of the star, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r   r  N)
r   r   r   _outer_radius_inner_radius_num_spikesr   r   ro   rp   )rq   rL   rK   r~  r  r  r   r   rg   ri   r   r   rj   r3   r   r   r   rr   s                    r"   rp   zStar.__init__	  s    b ))%!1a!1a0addS0
Nz5%	
 	
 	
 	
 	
r!   r&   r%   r7   c                &   t          |          dk    sJ t          | j        | j        f|t	          j        | j                            }| j        | j        z
  | j        | j        z
  f}| j	        | j
        z   dz  }t	          j        ||          |k     S r  )r9   r4   r   r   r,   r9  r   r   r   r  r  r.   )rq   r&   r$   r  s       r"   r   zStar.__contains__	  s    5zzQtw0%dn9U9UVV'DN*DGdn,DE$t'99Q>y''&00r!   c                   | j                             | j        | j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r#  r'  rv   s    r"   r   zStar._create_vertex_list	  r*  r!   r+  c           
        | j         s
d| j        z  S | j         }| j         }| j        }| j        }t          j        | j        z  }g }t          | j                  D ]}|
                    ||t          j        d|z  |z            z  z   ||t          j        d|z  |z            z  z   f           |
                    ||t          j        d|z  dz   |z            z  z   ||t          j        d|z  dz   |z            z  z   f           g }t          |          D ],\  }}	||g||dz
           |	R }
|                    |
           -|S )Nr-  r8  r+   )r   r   r   r   r  r  r,   r  r  r:  rP  r/   r0   r  r;  )rq   rL   rK   r_ir_od_thetar<  r;   r=  r&   r  s              r"   r)  zStar._get_vertices	  s   } 	,DO++^O^O   'D,, t'(( 	I 	IAMM1dhq1uw&?&? ?@dhq1uw&?&? ?@B C C CMM1dhA	W/D&E&E EFdhA	W/D&E&E EFH I I I I !&)) 	& 	&HAu!3fQUm3e33HOOH%%%%r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zStar._update_vertices
  rC  r!   c                    | j         S )z!Get/set outer radius of the star.)r  rv   s    r"   r~  zStar.outer_radius
       !!r!   r   c                <    || _         |                                  d S rt   )r  r   r   s     r"   r~  zStar.outer_radius
  "    "r!   c                    | j         S )z%Get/set the inner radius of the star.)r  rv   s    r"   r  zStar.inner_radius
  r  r!   c                <    || _         |                                  d S rt   )r  r   r   s     r"   r  zStar.inner_radius"
  r  r!   c                    | j         S )zNumber of spikes of the star.)r  rv   s    r"   r  zStar.num_spikes'
  s     r!   c                <    || _         |                                  d S rt   )r  r   r   s     r"   r  zStar.num_spikes,
  s"     r!   )rL   r(   rK   r(   r~  r(   r  r(   r  rh   r   r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  r  r  r   r	  )r   r   r   r   r   rp   r   r   r)  r   r  r~  r  r  r  r   r   s   @r"   r}  r}  	  sz        "FZ)4"&"&,0?
 ?
 ?
 ?
 ?
 ?
 ?
B1 1 1 1A A A A   8= = = = " " " X"         " " " X"               X                 r!   r}  c                  P     e Zd Zdeeddddd fdZddZddZddZddZ	 xZ
S ) Polygonr   N)r   rg   ri   r   r   rj   coordinates%tuple[float, float] | Sequence[float]r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                  d| _         t          |          | _        | j        d         \  | _        | _        |^}}	}
}||	|
|r|d         ndf| _        t                                          t          | j                  |||||           dS )a  Create a polygon.

        The polygon's anchor point defaults to the first vertex point.

        Args:
            coordinates:
                The coordinates for each point in the polygon. Each one
                must be able to unpack to a pair of float-like X and Y
                values.
            color:
                The RGB or RGBA color of the polygon, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   N)	r   rf  _coordinatesr   r   r   ro   rp   r9   )rq   r   rg   ri   r   r   rj   r  r3   r   r   r   rr   s               r"   rp   zPolygon.__init__3
  s    F  --,Q/1a!1a0addS0
!""z5%	
 	
 	
 	
 	
r!   r&   r%   r7   c                    t          |          dk    sJ t          | j        d         |t          j        | j                            }t          | j        | j        d         gz   |          S )Nr8  r   )r9   r4   r  r,   r9  r   r=   r   s     r"   r   zPolygon.__contains__a
  s]    5zzQd/2E4<;W;WXX !2d6G6J5K!KUSSSr!   c                8   |                                  }| j                            | j        | j        t          j        |          | j        | j        d|fd| j        | j        z  fd| j	        | j
        f| j        z  fd| j        f| j        z  f	  	        | _        d S r#  )r)  r   r  r   r   r
   r   r   r   r   r   r   r   )rq   r=  s     r"   r   zPolygon._create_vertex_listf
  s    %%'' M==OT_M(##K8_$*t67tw04?BCDN,t>? > A Ar!   r+  c                    | j         s
d| j        z  S | j        d         \  | j        z  | j        z  fd| j        D             }t          j        |g          d         S )Nr-  r   c                *    g | ]\  }}|z
  |z
  gS r    r    rt  s      r"   r4  z)Polygon._get_vertices.<locals>.<listcomp>y
  s*    KKKA1w;G,KKKr!   r=  )r   r   r  r   r   r
   flatten)rq   rw  ru  rv  s     @@r"   r)  zPolygon._get_verticesq
  s    } 	,DO++  ,Q/4>!4>!KKKKK9JKKK ~vh''
33r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zPolygon._update_vertices~
  rC  r!   )r  r  r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r  r   r^  )r   r   r   r   r   rp   r   r   r)  r   r   r   s   @r"   r  r  2
  s         G[)4"&"&,0,
 ,
 ,
 ,
 ,
 ,
 ,
 ,
\T T T T
	A 	A 	A 	A4 4 4 4= = = = = = = =r!   r  c            	           e Zd Zdddeeddddd  fdZd!dZd"dZd!dZe	d#d            Z
e
j        d$d            Z
 xZS )%	MultiLineFr>   r   N)r  rD   r   rg   ri   r   r   rj   r  r  r  r7   rD   r(   r   r   rg   rh   ri   r   r   r   rl   rj   r   r   rm   c                  || _         || _        d| _        t          |	          | _        |r%| j                            | j        d                    | j        d         \  | _        | _        |^}
}}}|
|||r|d         ndf| _        t                      
                    t          | j                  dz
  dz  |||||           dS )a  Create multiple connected lines from a series of coordinates.

        The shape's anchor point defaults to the first vertex point.

        Args:
            coordinates:
                The coordinates for each point in the shape. Each must
                unpack like a tuple consisting of an X and Y float-like
                value.
            closed:
                Set this to ``True`` to add a line connecting the first
                and last points. The default is ``False``
            thickness:
                The desired thickness or width used for the line segments.
            color:
                The RGB or RGBA color of the shape, specified as a
                tuple of 3 or 4 ints in the range of 0-255. RGB colors
                will be treated as having an opacity of 255.
            blend_src:
                OpenGL blend source mode; for example, ``GL_SRC_ALPHA``.
            blend_dest:
                OpenGL blend destination mode; for example, ``GL_ONE_MINUS_SRC_ALPHA``.
            batch:
                Optional batch to add the shape to.
            group:
                Optional parent group of the shape.
            program:
                Optional shader program of the shape.
        r   r   r+   r  N)r  r!  r   rf  r  rP  r   r   r   ro   rp   r9   )rq   r  rD   r   rg   ri   r   r   rj   r  r3   r   r   r   rr   s                 r"   rp   zMultiLine.__init__
  s    T $ -- 	;$$T%6q%9:::,Q/1a!1a0addS0
"##a'1,z5%	
 	
 	
 	
 	
r!   c                   | j                             | j        | j        | j        | j        d|                                 fd| j        | j        z  fd| j        | j	        f| j        z  fd| j
        f| j        z  f          | _        d S r#  r'  rv   s    r"   r   zMultiLine._create_vertex_list
  r*  r!   r+  c           
       	
 | j         s
d| j        z  S | j        d         \  	
	| j        z  	
| j        z  
	
fd| j        D             }g }d }d }t          t          |          dz
            D ]y}d }d }|dk    r||dz
           }|dz   t          |          k     r||dz            }t          |||         ||dz            || j        ||          ^}}}|	                    |           z|S )Nr-  r   c                *    g | ]\  }}|z
  |z
  gS r    r    rt  s      r"   r4  z+MultiLine._get_vertices.<locals>.<listcomp>
  s*    $^$^$^DAqa'k1w;%?$^$^$^r!   r+   r8  )
r   r   r  r   r   r:  r9   rd   r  r;  )rq   rw  	trianglesrE   rG   r;   r>  r?  r@  ru  rv  s            @@r"   r)  zMultiLine._get_vertices
  s1   } 	,DO++,Q/4>!4>!$^$^$^$^$^DL]$^$^$^ 	

s6{{Q'' 	& 	&A-1J-1J1uu#AE]
1us6{{""#AE]
/;Jq	SYZ[^_Z_S`bl<@OZYc0e 0e,J
WW%%%%r!   c                L    |                                  | j        j        d d <   d S rt   rB  rv   s    r"   r   zMultiLine._update_vertices
  rC  r!   c                    | j         S )z-Get/set the line thickness of the multi-line.rK  rv   s    r"   rD   zMultiLine.thickness
  rL  r!   c                <    || _         |                                  d S rt   rN  rO  s     r"   rD   zMultiLine.thickness
  rP  r!   )r  r  r  r7   rD   r(   r   r   rg   rh   ri   rh   r   r   r   rl   rj   r   r   rm   r   r^  r  r_  )r   r   r   r   r   rp   r   r)  r   r  rD   r  r   r   s   @r"   r  r  
  s        
 !"/C)4"&"&,09
 9
 9
 9
 9
 9
 9
 9
vA A A A   8= = = =    X                r!   r  )r  r1  rb  r  r  r  r  r  r   rk  r}  r  r  r   r  )r$   r%   r&   r%   r'   r(   r   r%   )r5   r6   r&   r%   r   r7   )r>   NN)r?   r@   rA   r@   rB   r@   rC   r@   rD   r(   rE   rF   rG   rF   r   rH   )8r   
__future__r   r,   abcr   r   typingr   r   r   r	   r   pyglet.extlibsr
   	pyglet.glr   r   r   r   r   r   r   pyglet.graphicsr   r   pyglet.mathr   pyglet.graphics.shaderr   r   r   r#   r4   r=   rd   rf   r   r  rb  r  r  r  r  r  r   r1  r(   _RadiusTshapesrG  rk  r}  r  r  __all__r    r!   r"   <module>r     s  A AD # " " " " "  # # # # # # # # 8 8 8 8 8 8 8 8 8 8 8 8  ! ! ! ! ! ! t t t t t t t t t t t t t t t t t t ( ( ( ( ( ( ( (       5444444 DS S S S
T T T T   4 dhTp Tp Tp Tp Tpn-R -R -R -R -R% -R -R -R`c' c' c' c' c' c' c' c'Lv  v  v  v  v ) v  v  v rM  M  M  M  M ) M  M  M `f  f  f  f  f Y f  f  f R}  }  }  }  } i }  }  } @]  ]  ]  ]  ] Y ]  ]  ] @K  K  K  K  K 9 K  K  K \l  l  l  l  l 	 l  l  l ^k k k k k	 k k k\M  M  M  M  M ) M  M  M ` eUl++,{  {  {  {  { v}. {  {  { |~  ~  ~  ~  ~ y ~  ~  ~ BL  L  L  L  L 9 L  L  L ^M= M= M= M= M=i M= M= M=`l  l  l  l  l 	 l  l  l ^Vr!   