
    g£                     ~    d Z ddlZddlmZ ddlmZ ddlZddlZ	ddl
mZmZ ddlmZmZ ddlmZ  G d	 d
      Zd Zy)a  
A module for dealing with the polylines used throughout Matplotlib.

The primary class for polyline handling in Matplotlib is `Path`.  Almost all
vector drawing makes use of `Path`\s somewhere in the drawing pipeline.

Whilst a `Path` instance itself cannot be drawn, some `.Artist` subclasses,
such as `.PathPatch` and `.PathCollection`, can be used for convenient `Path`
visualisation.
    N)	lru_cache)WeakValueDictionary   )_api_path)_to_unmasked_float_arraysimple_linear_interpolation)BezierSegmentc                   f    e Zd ZdZej
                  Z ed      Z ed      Z ed      Z	 ed      Z
 ed      Z ed      Zedede	de
dedediZ	 	 d8d
Zed9d       Zed        Zd Zed        Zej*                  d        Zed        Zej*                  d        Zed        Zej*                  d        Zed        Zej*                  d        Zed        Zd Zd9 fd	ZeZed        Zed        Zd Zd Z 	 	 	 d:dZ!d Z"d  Z#d;d	d	dd	dd!d"Z$d# Z%d<d$Z&d<d%Z'd9d&Z(d9d'Z)d=d(Z*d=d)Z+d* Z,d>d+Z-dZ.ed,        Z/ e0       Z1ed-        Z2 e0       Z3ed?d.       Z4ed/        Z5dZ6ed0        Z7ed@d1       Z8dZ9ed2        Z:edAd3       Z;ed9d4       Z<e= e>d5      dBd6              Z?d=d7Z@ xZAS )CPathu  
    A series of possibly disconnected, possibly closed, line and curve
    segments.

    The underlying storage is made up of two parallel numpy arrays:

    - *vertices*: an (N, 2) float array of vertices
    - *codes*: an N-length `numpy.uint8` array of path codes, or None

    These two arrays always have the same length in the first
    dimension.  For example, to represent a cubic curve, you must
    provide three vertices and three `CURVE4` codes.

    The code types are:

    - `STOP`   :  1 vertex (ignored)
        A marker for the end of the entire path (currently not required and
        ignored)

    - `MOVETO` :  1 vertex
        Pick up the pen and move to the given vertex.

    - `LINETO` :  1 vertex
        Draw a line from the current position to the given vertex.

    - `CURVE3` :  1 control point, 1 endpoint
        Draw a quadratic Bézier curve from the current position, with the given
        control point, to the given end point.

    - `CURVE4` :  2 control points, 1 endpoint
        Draw a cubic Bézier curve from the current position, with the given
        control points, to the given end point.

    - `CLOSEPOLY` : 1 vertex (ignored)
        Draw a line segment to the start point of the current polyline.

    If *codes* is None, it is interpreted as a `MOVETO` followed by a series
    of `LINETO`.

    Users of Path objects should not access the vertices and codes arrays
    directly.  Instead, they should use `iter_segments` or `cleaned` to get the
    vertex/code pairs.  This helps, in particular, to consistently handle the
    case of *codes* being None.

    Some behavior of Path objects can be controlled by rcParams. See the
    rcParams whose keys start with 'path.'.

    .. note::

        The vertices and codes arrays should be treated as
        immutable -- there are a number of optimizations and assumptions
        made up front in the constructor that will not change when the
        data changes.
    r   r            O   NFc                 f   t        |      }t        j                  d|       |t        |      rt	        j
                  || j                        }|j                  dk7  st        |      t        |      k7  r%t        d|j                   d|j                         t        |      r|d   | j                  k7  rt        d| j                   d	|d          |rbt        |      rWt	        j                  t        |      | j                  
      }| j                  |d<   | j                  |dd | j                  |d<   || _        || _        || _        | j#                          |rJd| j                  j$                  _        | j                  d| j                  j$                  _        d| _        yd| _        y)a  
        Create a new path with the given vertices and codes.

        Parameters
        ----------
        vertices : (N, 2) array-like
            The path vertices, as an array, masked array or sequence of pairs.
            Masked values, if any, will be converted to NaNs, which are then
            handled correctly by the Agg PathIterator and other consumers of
            path data, such as :meth:`iter_segments`.
        codes : array-like or None, optional
            N-length array of integers representing the codes of the path.
            If not None, codes must be the same length as vertices.
            If None, *vertices* will be treated as a series of line segments.
        _interpolation_steps : int, optional
            Used as a hint to certain projections, such as Polar, that this
            path should be linearly interpolated immediately before drawing.
            This attribute is primarily an implementation detail and is not
            intended for public use.
        closed : bool, optional
            If *codes* is None and closed is True, vertices will be treated as
            line segments of a closed polygon.  Note that the last vertex will
            then be ignored (as the corresponding code will be set to
            `CLOSEPOLY`).
        readonly : bool, optional
            Makes the path behave in an immutable way and sets the vertices
            and codes as read-only arrays.
        )Nr   )verticesNr   z`'codes' must be a 1D list or array with the same length of 'vertices'. Your vertices have shape z but your codes have shape r   z7The first element of 'code' must be equal to 'MOVETO' (z).  Your first code is dtypeFT)r   r   check_shapelennpasarray	code_typendim
ValueErrorshapeMOVETOemptyLINETO	CLOSEPOLY	_vertices_codes_interpolation_steps_update_valuesflags	writeable	_readonly)selfr   codesr$   closedreadonlys         B/var/www/html/venv/lib/python3.12/site-packages/matplotlib/path.py__init__zPath.__init__c   s   < ,H5X6XJJudnn5EzzQ#e*H"=  "==E^^<L M>>Ckk]"L M M 5zeAh$++5  "115 >77<Qxj"B C C HHHS]$..AE{{E!H++E!BKE"I!$8!-2DNN  *{{&.3!!+!DN"DN    c                    | j                  |       }t        |      |_        ||_        d|_        |5|j
                  |_        |j                  |_        |j                  |_        |S d|_        t        j                  d   |_        d|_        |S )a  
        Create a Path instance without the expense of calling the constructor.

        Parameters
        ----------
        verts : array-like
        codes : array
        internals_from : Path or None
            If not None, another `Path` from which the attributes
            ``should_simplify``, ``simplify_threshold``, and
            ``interpolation_steps`` will be copied.  Note that ``readonly`` is
            never copied, and always set to ``False`` by this constructor.
        FTpath.simplify_thresholdr   )
__new__r   r"   r#   r(   _should_simplify_simplify_thresholdr$   mplrcParams)clsvertsr*   internals_frompths        r-   _fast_from_codes_and_vertszPath._fast_from_codes_and_verts   s     kk#07
%#1#B#BC &4&H&HC#'5'J'JC$
 
 $(C &)ll3L&MC#'(C$
r/   c                 \    t        |      } | t        j                  ||dd g      d      S )z
        Create a closed polygonal path going through *vertices*.

        Unlike ``Path(..., closed=True)``, *vertices* should **not** end with
        an entry for the CLOSEPATH; this entry is added by `._create_closed`.
        Nr   T)r+   )r   r   concatenate)r7   r   vs      r-   _create_closedzPath._create_closed   s.     %X.2>>1ae*-d;;r/   c                 >   t         j                  d   | _        | j                  dkD  xro t         j                  d   xrZ t        | j                        dk\  xr@ | j
                  d u xs0 t        j                  | j
                  t        j                  k        | _
        y )Nr1   r   zpath.simplify   )r5   r6   r4   r   r"   r#   r   allr   r    r3   r)   s    r-   r%   zPath._update_values   s    #&<<0I#J $$q( HLL)H3&H [[D FBFF4;;$+++E$F	 	r/   c                     | j                   S )z.The vertices of the `Path` as an (N, 2) array.)r"   rC   s    r-   r   zPath.vertices   s     ~~r/   c                 `    | j                   rt        d      || _        | j                          y )Nz%Can't set vertices on a readonly Path)r(   AttributeErrorr"   r%   )r)   r   s     r-   r   zPath.vertices   s(    >> !HII!r/   c                     | j                   S )a\  
        The list of codes in the `Path` as a 1D array.

        Each code is one of `STOP`, `MOVETO`, `LINETO`, `CURVE3`, `CURVE4` or
        `CLOSEPOLY`.  For codes that correspond to more than one vertex
        (`CURVE3` and `CURVE4`), that code will be repeated so that the length
        of `vertices` and `codes` is always the same.
        )r#   rC   s    r-   r*   z
Path.codes   s     {{r/   c                 `    | j                   rt        d      || _        | j                          y )Nz"Can't set codes on a readonly Path)r(   rF   r#   r%   )r)   r*   s     r-   r*   z
Path.codes   s(    >> !EFFr/   c                     | j                   S )zi
        The fraction of a pixel difference below which vertices will
        be simplified out.
        r4   rC   s    r-   simplify_thresholdzPath.simplify_threshold   s     '''r/   c                     || _         y NrJ   )r)   	thresholds     r-   rK   zPath.simplify_threshold   s
    #, r/   c                     | j                   S )zD
        `True` if the vertices array should be simplified.
        r3   rC   s    r-   should_simplifyzPath.should_simplify   s    
 $$$r/   c                     || _         y rM   rP   )r)   rQ   s     r-   rQ   zPath.should_simplify  s
     /r/   c                     | j                   S )z4
        `True` if the `Path` is read-only.
        )r(   rC   s    r-   r,   zPath.readonly	  s    
 ~~r/   c                 ,    t        j                   |       S )z~
        Return a shallow copy of the `Path`, which will share the
        vertices and codes with the source `Path`.
        )copyrC   s    r-   rU   z	Path.copy  s    
 yyr/   c                 R    t        j                  t               |      }d|_        |S )zz
        Return a deepcopy of the `Path`.  The `Path` will not be
        readonly, even if the source `Path` is.
        F)rU   deepcopysuperr(   )r)   memop	__class__s      r-   __deepcopy__zPath.__deepcopy__  s#     MM%'4(r/   c                 t   |j                   \  }}}|dk7  rt        d      |dz   }||z  }t        j                  |df      }t        j                  || j
                  | j                        }| j                  |dd|<   | j                  ||d|<   t        |      D ]  }	|dd|	f   ||	d|<     | ||      S )z
        Make a compound `Path` object to draw a number of polygons with equal
        numbers of sides.

        .. plot:: gallery/misc/histogram_path.py

        Parameters
        ----------
        XY : (numpolys, numsides, 2) array
        r   z%The third dimension of 'XY' must be 2r   r   r   N)
r   r   r   zerosfullr    r   r   r!   range)
r7   XYnumpolysnumsidestwostridenvertsr8   r*   is
             r-   make_compound_path_from_polysz"Path.make_compound_path_from_polys#  s     #%(((C!8DEEAF"&!%

#--@::aii"%--hx 	(A!!Q$xE!)V)	(5%  r/   c                 *   |s0t        t        j                  ddgt        j                              S t        j                  |D cg c]  }|j
                   c}      }t        j                  t        |      | j                        }d}|D ]a  }t        |j
                        }|j                  '|r7| j                  ||<   | j                  ||dz   ||z    n|j                  ||||z    ||z  }c || j                  k7  } | ||   ||         S c c}w )z]
        Concatenate a list of `Path`\s into a single `Path`, removing all `STOP`\s.
        r   r   r   r   )r   r   r   float32r=   r   r   r   r*   r   r    STOP)r7   argspathr   r*   rg   sizenot_stop_masks           r-   make_compound_pathzPath.make_compound_path?  s    
 !Qrzz:;;>>T"BT4=="BCXcmm< 	Dt}}%Dzz!"zzE!H(+

E!A#af%"&**a$IA	 )8M*E-,@AA #Cs   Dc                 <    d| j                   d| j                  dS )NzPath(z, ))r   r*   rC   s    r-   __repr__zPath.__repr__U  s     t}}'r$**q99r/   c                 ,    t        | j                        S rM   )r   r   rC   s    r-   __len__zPath.__len__X  s    4==!!r/         ?c	           
   #     K   t        |       sy| j                  ||||||||      }	| j                  }
| j                  }t	        |	j
                        }t	        |	j                        }t        ||      D ]V  \  }}||k(  r y|
|   dz
  }|r:t        |      D ],  }t        |       t        j                  |t        |            }. ||f X yw)aN  
        Iterate over all curve segments in the path.

        Each iteration returns a pair ``(vertices, code)``, where ``vertices``
        is a sequence of 1-3 coordinate pairs, and ``code`` is a `Path` code.

        Additionally, this method can provide a number of standard cleanups and
        conversions to the path.

        Parameters
        ----------
        transform : None or :class:`~matplotlib.transforms.Transform`
            If not None, the given affine transformation will be applied to the
            path.
        remove_nans : bool, optional
            Whether to remove all NaNs from the path and skip over them using
            MOVETO commands.
        clip : None or (float, float, float, float), optional
            If not None, must be a four-tuple (x1, y1, x2, y2)
            defining a rectangle in which to clip the path.
        snap : None or bool, optional
            If True, snap all nodes to pixels; if False, don't snap them.
            If None, snap if the path contains only segments
            parallel to the x or y axes, and no more than 1024 of them.
        stroke_width : float, optional
            The width of the stroke being drawn (used for path snapping).
        simplify : None or bool, optional
            Whether to simplify the path by removing vertices
            that do not affect its appearance.  If None, use the
            :attr:`should_simplify` attribute.  See also :rc:`path.simplify`
            and :rc:`path.simplify_threshold`.
        curves : bool, optional
            If True, curve segments will be returned as curve segments.
            If False, all curves will be converted to line segments.
        sketch : None or sequence, optional
            If not None, must be a 3-tuple of the form
            (scale, length, randomness), representing the sketch parameters.
        N)	transformremove_nansclipsnapstroke_widthsimplifycurvessketchr   )r   cleanedNUM_VERTICES_FOR_CODErk   iterr   r*   zipr`   nextr   append)r)   rx   ry   rz   r{   r|   r}   r~   r   r   r   rk   r   r*   curr_verticescodeextra_verticesrg   s                     r-   iter_segmentszPath.iter_segments[  s     R 4y,,+6T$(|(0&,	  . !% : :yy(()W]]##&x#7 	&M4t|2481<N~. MAK$&IImT(^$LMM  %%	&s   CCc              +   4  K   d}d} | j                   di |D ]z  \  }}||t        j                  k7  rt        d      |t        j                  k(  r'|}t	        t        j                  |g            |f n|t        j                  k(  r%t	        t        j                  ||g            |f n|t        j                  k(  r,t	        t        j                  ||dd |dd g            |f n|t        j                  k(  r0t	        t        j                  ||dd |dd |dd g            |f n[|t        j                  k(  r%t	        t        j                  ||g            |f n#|t        j                  k(  r yt        d|       |dd }} yw)u~  
        Iterate over each Bézier curve (lines included) in a `Path`.

        Parameters
        ----------
        **kwargs
            Forwarded to `.iter_segments`.

        Yields
        ------
        B : `~matplotlib.bezier.BezierSegment`
            The Bézier curves that make up the current path. Note in particular
            that freestanding points are Bézier curves of order 0, and lines
            are Bézier curves of order 1 (with two control points).
        code : `~matplotlib.path.Path.code_type`
            The code describing what kind of curve is being returned.
            `MOVETO`, `LINETO`, `CURVE3`, and `CURVE4` correspond to
            Bézier curves with 1, 2, 3, and 4 control points (respectively).
            `CLOSEPOLY` is a `LINETO` with the control points correctly
            chosen based on the start/end points of the current stroke.
        Nz'Malformed path, must start with MOVETO.r   r   zInvalid Path.code_type:  )r   r   r   r   r
   r   arrayr    CURVE3CURVE4r!   rk   )r)   kwargs
first_vert	prev_vertr8   r   s         r-   iter_bezierzPath.iter_bezier  s    , 
	-4--77 	#KE4!4;;&$%NOOt{{""
#BHHj\$:;TAA$#BHHi-?$@A4GG$#BHHir.3ABi.9 %: ;<@A A$#BHHir.3Aaj%).E %F GHLM M'#BHHi-D$EFLL" #;D6!BCCbc
I+	#s   FFc              #   p  K   | j                   |  yt        j                  | j                   t        j                  k(  j                         d   t        | j                               }t        t        ||dd       D ]5  }t        j                  | j                  |   | j                   |   |        7 yw)z!Return subpaths split at MOVETOs.Nr   r   )r*   r   r   r   r   nonzeror   mapslicer;   r   )r)   idxssls      r-   _iter_connected_componentszPath._iter_connected_components  s     ::J99djjDKK7@@B1Es4::WD%tABx0 =55MM"%tzz"~t= ==s   B4B6)r}   r~   r|   r{   r   c                    t        j                  | ||||||||	      \  }	}
t        j                  |	|
|       }|sd|_        |S )z
        Return a new `Path` with vertices and codes cleaned according to the
        parameters.

        See Also
        --------
        Path.iter_segments : for details of the keyword arguments.
        F)r   cleanup_pathr   r;   r3   )r)   rx   ry   rz   r}   r~   r|   r{   r   r   r*   r:   s               r-   r   zPath.cleaned  sR      ,,)[$lHF% --htD#(C 
r/   c                 v    t        |j                  | j                        | j                  | j                        S )a  
        Return a transformed copy of the path.

        See Also
        --------
        matplotlib.transforms.TransformedPath
            A specialized path class that will cache the transformed result and
            automatically update when the transform changes.
        )r   rx   r   r*   r$   )r)   rx   s     r-   transformedzPath.transformed  s1     I''6

--/ 	/r/   c                     ||j                         }|r|j                  s|j                  |       } d}t        j                  |d   |d   || |      S )aZ  
        Return whether the area enclosed by the path contains the given point.

        The path is always treated as closed; i.e. if the last code is not
        `CLOSEPOLY` an implicit segment connecting the last vertex to the first
        vertex is assumed.

        Parameters
        ----------
        point : (float, float)
            The point (x, y) to check.
        transform : `~matplotlib.transforms.Transform`, optional
            If not ``None``, *point* will be compared to ``self`` transformed
            by *transform*; i.e. for a correct check, *transform* should
            transform the path into the coordinate system of *point*.
        radius : float, default: 0
            Additional margin on the path in coordinates of *point*.
            The path is extended tangentially by *radius/2*; i.e. if you would
            draw the path with a linewidth of *radius*, all points on the line
            would still be considered to be contained in the area. Conversely,
            negative values shrink the area: Points on the imaginary line
            will be considered outside the area.

        Returns
        -------
        bool

        Notes
        -----
        The current algorithm has some limitations:

        - The result is undefined for points exactly at the boundary
          (i.e. at the path shifted by *radius/2*).
        - The result is undefined if there is no enclosed area, i.e. all
          vertices are on a straight line.
        - If bounding lines start to cross each other due to *radius* shift,
          the result is not guaranteed to be correct.
        Nr   r   )frozen	is_affinetransform_pathr   point_in_path)r)   pointrx   radiuss       r-   contains_pointzPath.contains_point  s\    N  !((*I
 Y00++D1DI""58U1XvtYOOr/   c                 x    ||j                         }t        j                  ||| |      }|j                  d      S )a  
        Return whether the area enclosed by the path contains the given points.

        The path is always treated as closed; i.e. if the last code is not
        `CLOSEPOLY` an implicit segment connecting the last vertex to the first
        vertex is assumed.

        Parameters
        ----------
        points : (N, 2) array
            The points to check. Columns contain x and y values.
        transform : `~matplotlib.transforms.Transform`, optional
            If not ``None``, *points* will be compared to ``self`` transformed
            by *transform*; i.e. for a correct check, *transform* should
            transform the path into the coordinate system of *points*.
        radius : float, default: 0
            Additional margin on the path in coordinates of *points*.
            The path is extended tangentially by *radius/2*; i.e. if you would
            draw the path with a linewidth of *radius*, all points on the line
            would still be considered to be contained in the area. Conversely,
            negative values shrink the area: Points on the imaginary line
            will be considered outside the area.

        Returns
        -------
        length-N bool array

        Notes
        -----
        The current algorithm has some limitations:

        - The result is undefined for points exactly at the boundary
          (i.e. at the path shifted by *radius/2*).
        - The result is undefined if there is no enclosed area, i.e. all
          vertices are on a straight line.
        - If bounding lines start to cross each other due to *radius* shift,
          the result is not guaranteed to be correct.
        bool)r   r   points_in_pathastype)r)   pointsrx   r   results        r-   contains_pointszPath.contains_points(  s>    N  !((*I%%ffdIF}}V$$r/   c                 V    ||j                         }t        j                  | d||      S )z
        Return whether this (closed) path completely contains the given path.

        If *transform* is not ``None``, the path will be transformed before
        checking for containment.
        N)r   r   path_in_path)r)   rm   rx   s      r-   contains_pathzPath.contains_pathT  s/      !((*I!!$dI>>r/   c                    ddl m} ||j                  |       } | j                  | j                  }nt        t        j                  | j                  t        j                  t        j                  g            dk(  rL| j                  t        j                  | j                  t        j                  t        j                  g         }n`g } | j                  di |D ]4  \  }}|j                         \  }}|j!                   |dg|d             6 t        j"                  |      }t        |      r* ||j%                  d      |j'                  d      g      S |j)                         S )a  
        Get Bbox of the path.

        Parameters
        ----------
        transform : `~matplotlib.transforms.Transform`, optional
            Transform to apply to path before computing extents, if any.
        **kwargs
            Forwarded to `.iter_bezier`.

        Returns
        -------
        matplotlib.transforms.Bbox
            The extents of the path Bbox([[xmin, ymin], [xmax, ymax]])
        r   Bboxr   )axisr   )
transformsr   r   r*   r   r   r   intersect1dr   r   r   isinr   r    r   axis_aligned_extremar   r=   minmaxnull)	r)   rx   r   r   xyscurver   _dzeross	            r-   get_extentszPath.get_extents_  s*     	% ++D1D::--C

T[[$++,FGHAM
 --

)-dkk(B!D EC C/t//9&9 3t!668	6

5!fa12	3
 ..%Cs8a#''q'/:;;99;r/   c                 0    t        j                  | ||      S )z
        Return whether if this path intersects another given path.

        If *filled* is True, then this also returns True if one path completely
        encloses the other (i.e., the paths are treated as filled).
        )r   path_intersects_path)r)   otherfilleds      r-   intersects_pathzPath.intersects_path  s     ))$v>>r/   c                     t        j                  | |j                  |j                  |j                  |j
                  |      S )a  
        Return whether this path intersects a given `~.transforms.Bbox`.

        If *filled* is True, then this also returns True if the path completely
        encloses the `.Bbox` (i.e., the path is treated as filled).

        The bounding box is always considered filled.
        )r   path_intersects_rectanglex0y0x1y1)r)   bboxr   s      r-   intersects_bboxzPath.intersects_bbox  s4     ..$''477DGGTWWf> 	>r/   c                 
   |dk(  r| S t        | j                  |      }| j                  }|Kt        j                  t        |      dz
  |z  dz   t        j                  | j                        }||dd|<   nd}t        ||      S )z
        Return a new path resampled to length N x *steps*.

        Codes other than `LINETO` are not handled correctly.
        r   Nr   r   )	r	   r   r*   r   r_   r   r   r    r   )r)   stepsr   r*   	new_codess        r-   interpolatedzPath.interpolated  s     A:K.t}}eD

Ua5 81 <dkk&*nn6I"'IahhIHi((r/   c                 p   t        | j                        dk(  rg S ||j                         }| j                  f|dk(  s|dk(  r\| j                  }|r7t        |      dk  rg S t	        j
                  |d   |d   k7        r	g ||d   }||gS |j                  |      gS t        j                  | ||||      S )uH  
        Convert this path to a list of polygons or polylines.  Each
        polygon/polyline is an (N, 2) array of vertices.  In other words,
        each polygon has no `MOVETO` instructions or curves.  This
        is useful for displaying in backends that do not support
        compound paths or Bézier curves.

        If *width* and *height* are both non-zero then the lines will
        be simplified so that vertices outside of (0, 0), (width,
        height) will be clipped.

        The resulting polygons will be simplified if the
        :attr:`Path.should_simplify` attribute of the path is `True`.

        If *closed_only* is `True` (default), only closed polygons,
        with the last point being the same as the first point, will be
        returned.  Any unclosed polylines in the path will be
        explicitly closed.  If *closed_only* is `False`, any unclosed
        polygons in the path will be returned as unclosed polygons,
        and the closed polygons will be returned explicitly closed by
        setting the last point to the same as the first point.
        r   r   r   )	r   r   r   r*   r   anyrx   r   convert_path_to_polygons)r)   rx   widthheightclosed_onlyr   s         r-   to_polygonszPath.to_polygons  s    . t}}"I !((*I::5A:1}}Hx=1$IVVHQK8B<78778A;7H  z!!++H566 --)UFK9 	9r/   c                 p    | j                    | ddgddgddgddgddggdd      | _         | j                   S )zW
        Return a `Path` instance of the unit rectangle from (0, 0) to (1, 1).
        r   r   Tr+   r,   )_unit_rectangler7   s    r-   unit_rectanglezPath.unit_rectangle  sP    
 &"%1v1v1v1v1v&N-1D#BC"""r/   c                    |dk  r| j                   j                  |      }nd}|dt        j                  z  |z  t        j                  |dz         z  t        j                  dz  z   }t        j
                  t        j                  |      t        j                  |      f      } | |dd      }|dk  r|| j                   |<   |S )z
        Return a :class:`Path` instance for a unit regular polygon with the
        given *numVertices* such that the circumscribing circle has radius 1.0,
        centered at (0, 0).
           Nr   r   Tr   )_unit_regular_polygonsgetr   piarangecolumn_stackcossin)r7   numVerticesrm   thetar8   s        r-   unit_regular_polygonzPath.unit_regular_polygon  s     "--11+>DD<"%%i+-;?1KK uuqy!E OORVVE]BFF5M$BCEuTD9Db :>**;7r/   c                    |dk  r| j                   j                  ||f      }nd}||dz  }dt        j                  z  |z  t        j                  |dz         z  }|t        j                  dz  z  }t        j
                  |dz         }||ddd<   |t        j                  t        j                  |      t        j                  |      f      z  j                  } | |dd      }|dk  r|| j                   ||f<   |S )z
        Return a :class:`Path` for a unit regular star with the given
        numVertices and radius of 1.0, centered at (0, 0).
        r   Nr   r   g       @Tr   )
_unit_regular_starsr   r   r   r   onesvstackr   r   T)r7   r   innerCirclerm   ns2r   rr8   s           r-   unit_regular_starzPath.unit_regular_star  s     "**..[/IJDD</CruuWS[299S1W#55E RUUS[ Ea A!AaddGBFF5M266%=#ABBEEEuTD9Db FJ''k(BCr/   c                 &    | j                  |d      S )z
        Return a :class:`Path` for a unit regular asterisk with the given
        numVertices and radius of 1.0, centered at (0, 0).
                )r   )r7   r   s     r-   unit_regular_asteriskzPath.unit_regular_asterisk  s     $$[#66r/   c                 d    | j                   | j                  ddd      | _         | j                   S )z
        Return the readonly :class:`Path` of the unit circle.

        For most cases, :func:`Path.circle` will be what you want.
        )r   r   r   T)centerr   r,   )_unit_circlecircler   s    r-   unit_circlezPath.unit_circle'  s9     #"zz37  *  9Cr/   c                    d}t        j                  d      }||z  }t        j                  ddg|dg||z
  | |z
  g|| g||z   | |z   gd| gddgd|g||z   ||z
  g||g||z
  ||z   g|dgddg| dg| |z   ||z   g| |g| |z
  ||z
  gd|gddgd| g| |z
  | |z   g| | g| |z   | |z
  g| dgddgddggt              }| j                  gdz  }| j
                  |d<   | j                  |d	<   t        ||z  |z   ||
      S )u  
        Return a `Path` representing a circle of a given radius and center.

        Parameters
        ----------
        center : (float, float), default: (0, 0)
            The center of the circle.
        radius : float, default: 1
            The radius of the circle.
        readonly : bool
            Whether the created path should have the "readonly" argument
            set when creating the Path instance.

        Notes
        -----
        The circle is approximated using 8 cubic Bézier curves, as described in

          Lancaster, Don.  `Approximating a Circle or an Ellipse Using Four
          Bezier Cubic Splines <https://www.tinaja.com/glib/ellipse4.pdf>`_.
        rSl?      ?r         rv   r      r   r   r,   )r   sqrtr   floatr   r   r!   r   )	r7   r   r   r,   MAGICSQRTHALFMAGIC45r   r*   s	            r-   r   zPath.circle3  s   , 773<U"88c4[#T]&w.	'0AB&	2&w.	'0AB!E6]!3Z!5\&w.0@A&1&w.0@A#S\!3Z$fc]'i/'1AB'i2'i/'1AB"E]"C["UF^'i/(71BC'i(3'i/(71BC$fd^!4[!4[E"*F #(G#)J r!::aMMb	Hv%.IIr/   c                    | j                   d}t        j                  d      }||z  }t        j                  ddg|dg||z
  | |z
  g|| g||z   | |z   gd| gddgd|g||z   ||z
  g||g||z
  ||z   g|dgddgddggt              }t        j
                  d| j                  | j                        }| j                  |d<   | j                  |d	<    | ||d
      | _         | j                   S )z
        Return a `Path` of the right half of a unit circle.

        See `Path.circle` for the reference on the approximation used.
        r   r   r   r   rv      r   r   r   Tr   )
_unit_circle_righthalfr   r  r   r  r_   r   r   r   r!   )r7   r  r  r  r   r*   s         r-   unit_circle_righthalfzPath.unit_circle_righthalfy  s/    %%-Ewws|H&Gxxt7"XIg$56XI&7"XIg$56vsu7"HW$45H%7"HW$45st%( +H. GGB

#--@EzzE!HE"I),Xut)LC&)))r/   c                    t         j                  dz  }|}|dt        j                  ||z
  dz        z  z
  }||k7  r
||k  r|dz  }t        j                  ||g      \  }}|'t	        dt        j
                  ||z
  |z        z        }|dk  rt        d      ||z
  |z  }t        j                  d|z        }	t        j                  |      t        j                  dd|	z  |	z  z         dz
  z  dz  }
t        j                  |||dz   d	      }t        j                  |      }t        j                  |      }|dd
 }|dd
 }| }|}|dd }|dd }| }|}|r|dz  dz   }t        j                  |dft              }t        j                  || j                  | j                         }|d   |d   g|d<   | j"                  | j$                  g|dd | j$                  | j&                  g|dd d}|dz
  }np|dz  dz   }t        j(                  |dft              }t        j                  || j                  | j                         }|d   |d   g|d<   | j"                  |d<   d}|}||
|z  z   |||ddf<   ||
|z  z   |||ddf<   ||
|z  z
  ||dz   |ddf<   ||
|z  z
  ||dz   |ddf<   |||dz   |ddf<   |||dz   |ddf<    | ||d	      S )a  
        Return a `Path` for the unit circle arc from angles *theta1* to
        *theta2* (in degrees).

        *theta2* is unwrapped to produce the shortest arc within 360 degrees.
        That is, if *theta2* > *theta1* + 360, the arc will be from *theta1* to
        *theta2* - 360 and not a full circle plus some extra overlap.

        If *n* is provided, it is the number of spline segments to make.
        If *n* is not provided, the number of spline segments is
        determined based on the delta between *theta1* and *theta2*.

           Masionobe, L.  2003.  `Drawing an elliptical arc using
           polylines, quadratic or cubic Bezier curves
           <https://web.archive.org/web/20190318044212/http://www.spaceroots.org/documents/ellipse/index.html>`_.
        r   ih  Nr   r   zn must be >= 1 or Noneg      @g      @Tr   r   r   r   r   r   r   )r   r   floordeg2radintceilr   tanr   r  linspacer   r^   r  r_   r   r   r   r    r!   r   )r7   theta1theta2nis_wedgehalfpieta1eta2detatalphar   cos_etasin_etaxAyAxA_dotyA_dotxByBxB_dotyB_dotlengthr   r*   vertex_offsetends                              r-   arczPath.arc  s(   $ bhh3'>??? VCKDZZt-
d 9A$+!7889Aq5566tq FF3:tcAgk(9 :Q >?#ED$At4&&-&&-Sb\Sb\QR[QR[UQYFxxU3HGGFCJJcmmDEa5"Q%.HQK**cjj1E!AJ**cmm4E"#JM1*CUQYFxxU3HGGFCJJcmmDEa5"Q%.HQKzzE!HMC+-+>s1$a'(+-+>s1$a'(-/%&.-@qQ&)*-/%&.-@qQ&)*-/qQ&)*-/qQ&)*8UT22r/   c                 *    | j                  |||d      S )ap  
        Return a `Path` for the unit circle wedge from angles *theta1* to
        *theta2* (in degrees).

        *theta2* is unwrapped to produce the shortest wedge within 360 degrees.
        That is, if *theta2* > *theta1* + 360, the wedge will be from *theta1*
        to *theta2* - 360 and not a full circle plus some extra overlap.

        If *n* is provided, it is the number of spline segments to make.
        If *n* is not provided, the number of spline segments is
        determined based on the delta between *theta1* and *theta2*.

        See `Path.arc` for the reference on the approximation used.
        T)r(  )r7   r  r  r  s       r-   wedgez
Path.wedge  s      wwvvq$//r/      c                 (    ddl m} | 	 || |      S dS )z
        Given a hatch specifier, *hatchpattern*, generates a `Path` that
        can be used in a repeated hatching pattern.  *density* is the
        number of lines per unit square.
        r   )get_pathN)matplotlib.hatchr-  )hatchpatterndensityr-  s      r-   hatchz
Path.hatch  s&     	.+ w/ 	715	7r/   c                     t        j                  | ||      }|D cg c]  }t        |       }} | j                  | S c c}w )a.  
        Clip the path to the given bounding box.

        The path must be made up of one or more closed polygons.  This
        algorithm will not behave correctly for unclosed paths.

        If *inside* is `True`, clip to the inside of the box, otherwise
        to the outside of the box.
        )r   clip_path_to_rectr   rp   )r)   r   insider8   polypathss         r-   clip_to_bboxzPath.clip_to_bbox  sG     ''dF;(-.d..&t&&.. /s   ?)Nr   FFrM   )NTNFrv   NTN)NFN)Nr   )T)Nr   r   T)r   ))r   r   rv   F)NF)   )B__name__
__module____qualname____doc__r   uint8r   rk   r   r    r   r   r!   r   r.   classmethodr;   r?   r%   propertyr   setterr*   rK   rQ   r,   rU   r\   rW   rh   rp   rs   ru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r	  r(  r*  staticmethodr   r1  r7  __classcell__)r[   s   @r-   r   r      s'   5n I Q<Dq\Fq\Fq\Fq\F"I "1#Q#Q#Q#Q&+ CD(-=#~  8 < <
   __  	 	 \\  ( ( - - % % 0 0   H! !6 B B*:" DH=A*.@&D-#^=!% uT&/0Pd*%X	?'R?
>)&-9^ O# # 12 * ./ . 7 7 L	  	  AJ AJF "'* '*R L3 L3\ 0 0" q\7  7/r/   r   c                     ddl m} t        |      dk(  rt        d      t        |      dk(  rt        d      t	        j
                  | |t        j                  |      ||      \  }} |j                  |d|iS )u	  
    Get bounding box of a `.PathCollection`\s internal objects.

    That is, given a sequence of `Path`\s, `.Transform`\s objects, and offsets, as found
    in a `.PathCollection`, return the bounding box that encapsulates all of them.

    Parameters
    ----------
    master_transform : `~matplotlib.transforms.Transform`
        Global transformation applied to all paths.
    paths : list of `Path`
    transforms : list of `~matplotlib.transforms.Affine2DBase`
        If non-empty, this overrides *master_transform*.
    offsets : (N, 2) array-like
    offset_transform : `~matplotlib.transforms.Affine2DBase`
        Transform applied to the offsets before offsetting the path.

    Notes
    -----
    The way that *paths*, *transforms* and *offsets* are combined follows the same
    method as for collections: each is iterated over independently, so if you have 3
    paths (A, B, C), 2 transforms (α, β) and 1 offset (O), their combinations are as
    follows:

    - (A, α, O)
    - (B, β, O)
    - (C, α, O)
    r   r   r   zNo paths providedzNo offsets providedminpos)	r   r   r   r   r   get_path_collection_extentsr   
atleast_3dfrom_extents)master_transformr6  r   offsetsoffset_transformr   extentsrD  s           r-   rE  rE    sz    < !
5zQ,--
7|q.//77%z!:!#OGV 4g5f55r/   )r<  rU   	functoolsr   weakrefr   numpyr   
matplotlibr5    r   r   cbookr   r	   bezierr
   r   rE  r   r/   r-   <module>rS     s6   	   '    H !D/ D/N &6r/   