
    hG                     $   S r SSKJr  SSKJr  SSKJr  SSKJr	  SSK
Jr  SSKr " S S	5      r " S
 S\5      r " S S\5      rS r " S S\5      r\" \S9r " S S\5      r\" \S9r " S S\5      r " S S\5      r " S S\5      r\" \S9rg)z
Defines classes for path effects. The path effects are supported in `.Text`,
`.Line2D` and `.Patch`.

.. seealso::
   :ref:`patheffects_guide`
    )RendererBase)colors)patches)
transforms)PathNc                   8    \ rS rSrSrS	S jrS rS rS
S jrSr	g)AbstractPathEffect   zr
A base class for path effects.

Subclasses should override the ``draw_path`` method to add effect
functionality.
c                     Xl         g)z
Parameters
----------
offset : (float, float), default: (0, 0)
    The (x, y) offset to apply to the path, measured in points.
N_offset)selfoffsets     H/var/www/html/env/lib/python3.13/site-packages/matplotlib/patheffects.py__init__AbstractPathEffect.__init__   s	         c                     [         R                  " 5       R                  " [        UR                  U R
                  5      6 $ )z(Apply the offset to the given transform.)mtransformsAffine2D	translatemappoints_to_pixelsr   )r   renderers     r   _offset_transform$AbstractPathEffect._offset_transform"   s2    ##%//**DLL9; 	;r   c                    UR                  5       nUR                  SS5      nU(       a  UR                  " S0 UD6  UR                  5        H;  u  pE[	        USU-   S5      n[        U5      (       d  [        SU 35      eU" U5        M=     U$ )z
Update the given GraphicsContext with the given dict of properties.

The keys in the dictionary are used to identify the appropriate
``set_`` method on the *gc*.
dashesNset_zUnknown property  )copypop
set_dashesitemsgetattrcallableAttributeError)r   gcnew_gc_dictr   kv
set_methods          r   
_update_gcAbstractPathEffect._update_gc'   s     "&&(40MM#F#%%'DA VaZ6JJ''$'8%<==qM	 (
 	r   Nc                 h    [        U[        5      (       a  UR                  nUR                  X#XE5      $ )z
Derived should override this method. The arguments are the same
as :meth:`matplotlib.backend_bases.RendererBase.draw_path`
except the first argument is a renderer.
)
isinstancePathEffectRenderer	_renderer	draw_path)r   r   r(   tpathaffinergbFaces         r   r3   AbstractPathEffect.draw_path;   s0     h 233))H!!"V==r   r   ))        r8   N)
__name__
__module____qualname____firstlineno____doc__r   r   r-   r3   __static_attributes__r    r   r   r	   r	      s    ;
(	>r   r	   c                   d   ^  \ rS rSrSrS rS rS rSS jrU 4S jr	U 4S jr
SS	 jrS
 rSrU =r$ )r1   G   aW  
Implements a Renderer which contains another renderer.

This proxy then intercepts draw calls, calling the appropriate
:class:`AbstractPathEffect` draw method.

.. note::
    Not all methods have been overridden on this RendererBase subclass.
    It may be necessary to add further methods to extend the PathEffects
    capabilities further.
c                     Xl         X l        g)z
Parameters
----------
path_effects : iterable of :class:`AbstractPathEffect`
    The path effects which this renderer represents.
renderer : `~matplotlib.backend_bases.RendererBase` subclass

N_path_effectsr2   )r   path_effectsr   s      r   r   PathEffectRenderer.__init__T   s     *!r   c                 8    U R                  XR                  5      $ r9   )	__class__r2   )r   rE   s     r   copy_with_path_effect(PathEffectRenderer.copy_with_path_effect`   s    ~~lNN;;r   c                 d    US;   a  [        U R                  U5      $ [        R                  X5      $ )N)flipyget_canvas_width_heightnew_gcr   
_text2pathheightwidth)r%   r2   object__getattribute__)r   names     r   rS   #PathEffectRenderer.__getattribute__c   s3     I I4>>400**466r   c                 f    U R                    H!  nUR                  U R                  XUU5        M#     g r9   )rD   r3   r2   )r   r(   r4   r5   r6   path_effects         r   r3   PathEffectRenderer.draw_pathj   s-    --K!!$.."V")+ .r   c                    > [        U R                  5      S:X  a  [        T	U ]  " XX4/UQ70 UD6$ U R                   H,  nU R	                  U/5      nUR                  " XX4/UQ70 UD6  M.     g N   )lenrD   superdraw_markersrI   )
r   r(   marker_pathmarker_transpathargskwargsrW   r   rH   s
            r   r^   PathEffectRenderer.draw_markerso   s    
 t!!"a' 7' 9)-9179 9  --K11;-@H !!"< 3#'3+13	 .r   c                    > [        U R                  5      S:X  a  [        TU ]  " XU/UQ70 UD6$ U R                   H,  nU R	                  U/5      nUR                  " XU/UQ70 UD6  M.     g rZ   )r\   rD   r]   draw_path_collectionrI   )	r   r(   master_transformpathsrb   rc   rW   r   rH   s	           r   rf   'PathEffectRenderer.draw_path_collection   s    
 t!!"a' 7/e A15A9?A A  --K11;-@H ))" ;+/;39;	 .r   c                 8    U R                   R                  X5      $ r9   )r2   
open_group)r   sgids      r   rk   PathEffectRenderer.open_group   s    ~~((00r   c                 8    U R                   R                  U5      $ r9   )r2   close_group)r   rl   s     r   rp   PathEffectRenderer.close_group   s    ~~))!,,r   rC   r9   )r:   r;   r<   r=   r>   r   rI   rS   r3   r^   rf   rk   rp   r?   __classcell__rH   s   @r   r1   r1   G   s5    

"<7+
3$;$1- -r   r1   c                       \ rS rSrSrSrg)Normal   z~
The "identity" PathEffect.

The Normal PathEffect's sole purpose is to draw the original artist with
no special path effect.
r    N)r:   r;   r<   r=   r>   r?   r    r   r   ru   ru      s    r   ru   c                     " S SU 5      nSU R                    3Ul         SU R                    3Ul        SU R                    SU R                    SU R                    S3Ul        U R                  R                  UR                  l        U$ )zG
Create a PathEffect class combining *effect_class* and a normal draw.
c                   (   ^  \ rS rSrU 4S jrSrU =r$ ))_subclass_with_normal.<locals>.withEffect   c                 L   > [         TU ]  XX4U5        UR                  X#XE5        g r9   )r]   r3   )r   r   r(   r4   r5   r6   rH   s         r   r3   3_subclass_with_normal.<locals>.withEffect.draw_path   s$    GhE7Cr&:r   r    )r:   r;   r<   r=   r3   r?   rr   rs   s   @r   
withEffectry      s    	; 	;r   r}   withz*
    A shortcut PathEffect for applying `.z` and then
    drawing the original Artist.

    With this class you can use ::

        artist.set_path_effects([patheffects.withzM()])

    as a shortcut for ::

        artist.set_path_effects([patheffects.z@(),
                                 patheffects.Normal()])
    )r:   r<   r>   r3   )effect_classr}   s     r   _subclass_with_normalr      s    
;\ ;
 !!6!6 78J $\%:%:$;<J**6*?*?)@ A2
 3?2G2G1H I. /;.C.C-D EJ $0#9#9#A#AJ r   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )Stroke   z0A line based PathEffect which re-draws a stroke.c                 0   > [         TU ]  U5        X l        g)z
The path will be stroked with its gc updated with the given
keyword arguments, i.e., the keyword arguments should be valid
gc parameter values.
N)r]   r   _gcr   r   rc   rH   s      r   r   Stroke.__init__   s     	 r   c                     UR                  5       nUR                  U5        U R                  X`R                  5      nUR	                  XcX@R                  U5      -   U5        UR                  5         g)Draw the path with updated gc.N)rN   copy_propertiesr-   r   r3   r   restore)r   r   r(   r4   r5   r6   gc0s          r   r3   Stroke.draw_path   s[    ooBooc88,!7!7!AA7	Lr   )r   r   r   	r:   r;   r<   r=   r>   r   r3   r?   rr   rs   s   @r   r   r      s    : r   r   )r   c                   <   ^  \ rS rSrSr   SU 4S jjrS rSrU =r$ )SimplePatchShadow   z#A simple shadow via a filled patch.c                    > [         TU ]  U5        Uc  X l        O[        R                  " U5      U l        Uc  SnX0l        X@l        XPl        g)a  
Parameters
----------
offset : (float, float), default: (2, -2)
    The (x, y) offset of the shadow in points.
shadow_rgbFace : :mpltype:`color`
    The shadow color.
alpha : float, default: 0.3
    The alpha transparency of the created shadow patch.
rho : float, default: 0.3
    A scale factor to apply to the rgbFace color if *shadow_rgbFace*
    is not specified.
**kwargs
    Extra keywords are stored and passed through to
    :meth:`AbstractPathEffect._update_gc`.

N333333?)r]   r   _shadow_rgbFacemcolorsto_rgba_alpha_rhor   )r   r   shadow_rgbFacealpharhorc   rH   s         r   r   SimplePatchShadow.__init__   sJ    ( 	 !#1 #*??>#BD =E	 r   c                    UR                  5       nUR                  U5        U R                  c;  U=(       d    SSS u  pxn	XpR                  -  XR                  -  XR                  -  4n
OU R                  n
UR	                  S5        UR                  U R                  5        UR                  S5        U R                  X`R                  5      nUR                  XcX@R                  U5      -   U
5        UR                  5         g)g
Overrides the standard draw_path to add the shadow offset and
necessary color changes for the shadow.
N      ?r   r      noner   )rN   r   r   r   set_foreground	set_alphar   set_linewidthr-   r   r3   r   r   r   r   r(   r4   r5   r6   r   rgbr   s              r   r3   SimplePatchShadow.draw_path  s    
 ooB'.,3GA!))mQ]A		MJN!11N6"dkk"!ooc88,!7!7!AA	 	r   )r   r   r   r   )   NNr   r   rs   s   @r   r   r      s    -%,0"H r   r   c                   :   ^  \ rS rSrSr  SU 4S jjrS rSrU =r$ )SimpleLineShadowi  zA simple shadow via a line.c                    > [         TU ]  U5        Uc  X l        O[        R                  " U5      U l        X0l        X@l        XPl        g)aF  
Parameters
----------
offset : (float, float), default: (2, -2)
    The (x, y) offset to apply to the path, in points.
shadow_color : :mpltype:`color`, default: 'black'
    The shadow color.
    A value of ``None`` takes the original artist's color
    with a scale factor of *rho*.
alpha : float, default: 0.3
    The alpha transparency of the created shadow patch.
rho : float, default: 0.3
    A scale factor to apply to the rgbFace color if *shadow_color*
    is ``None``.
**kwargs
    Extra keywords are stored and passed through to
    :meth:`AbstractPathEffect._update_gc`.
N)r]   r   _shadow_colorr   r   r   r   r   )r   r   shadow_colorr   r   rc   rH   s         r   r   SimpleLineShadow.__init__!  s>    ( 	 !-!(!>D	r   c                    UR                  5       nUR                  U5        U R                  cI  UR                  5       =(       d    SSS u  pxn	XpR                  -  XR                  -  XR                  -  4n
OU R                  n
UR                  U
5        UR                  U R                  5        U R                  X`R                  5      nUR                  XcX@R                  U5      -   5        UR                  5         g)r   Nr   r   )rN   r   r   get_foregroundr   r   r   r   r-   r   r3   r   r   r   s              r   r3   SimpleLineShadow.draw_path?  s    
 ooB%))+;|Ra@GA!))mQ]A		MJN!//N>*dkk"ooc88,!7!7!AA	Cr   )r   r   r   r   )r   r*   r   r   r   rs   s   @r   r   r     s    %%25< r   r   c                   6   ^  \ rS rSrSrSU 4S jjrS rSrU =r$ )PathPatchEffectiW  zU
Draws a `.PathPatch` instance whose Path comes from the original
PathEffect artist.
c                 X   > [         TU ]  US9  [        R                  " / 40 UD6U l        g)aR  
Parameters
----------
offset : (float, float), default: (0, 0)
    The (x, y) offset to apply to the path, in points.
**kwargs
    All keyword arguments are passed through to the
    :class:`~matplotlib.patches.PathPatch` constructor. The
    properties which cannot be overridden are "path", "clip_box"
    "transform" and "clip_path".
)r   N)r]   r   mpatches	PathPatchpatchr   s      r   r   PathPatchEffect.__init__]  s,     	'''5f5
r   c                    X0R                   l        U R                   R                  X@R                  U5      -   5        U R                   R	                  UR                  5       5        UR                  5       nU(       a4  U R                   R                  5       c  U R                   R                  " U6   U R                   R                  U5        g r9   )	r   _pathset_transformr   set_clip_boxget_clip_rectangleget_clip_pathset_clip_pathdraw)r   r   r(   r4   r5   r6   	clip_paths          r   r3   PathPatchEffect.draw_pathl  s     



  *@*@*J!JK

 5 5 78$$&	113;JJ$$i0

!r   )r   r   r   rs   s   @r   r   r   W  s    
6" "r   r   c                   ^   ^  \ rS rSrSrSSS\R                  " S5      4U 4S jjrS rS	r	U =r
$ )
TickedStrokeiv  a  
A line-based PathEffect which draws a path with a ticked style.

This line style is frequently used to represent constraints in
optimization.  The ticks may be used to indicate that one side
of the line is invalid or to represent a closed boundary of a
domain (i.e. a wall or the edge of a pipe).

The spacing, length, and angle of ticks can be controlled.

This line style is sometimes referred to as a hatched line.

See also the :doc:`/gallery/misc/tickedstroke_demo` example.
r   g      $@g     F@r   c                 T   > [         TU ]  U5        X l        X0l        X@l        XPl        g)am  
Parameters
----------
offset : (float, float), default: (0, 0)
    The (x, y) offset to apply to the path, in points.
spacing : float, default: 10.0
    The spacing between ticks in points.
angle : float, default: 45.0
    The angle between the path and the tick in degrees.  The angle
    is measured as if you were an ant walking along the curve, with
    zero degrees pointing directly ahead, 90 to your left, -90
    to your right, and 180 behind you. To change side of the ticks,
    change sign of the angle.
length : float, default: 1.414
    The length of the tick relative to spacing.
    Recommended length = 1.414 (sqrt(2)) when angle=45, length=1.0
    when angle=90 and length=2.0 when angle=60.
**kwargs
    Extra keywords are stored and passed through to
    :meth:`AbstractPathEffect._update_gc`.

Examples
--------
See :doc:`/gallery/misc/tickedstroke_demo`.
N)r]   r   _spacing_angle_lengthr   )r   r   spacinganglelengthrc   rH   s         r   r   TickedStroke.__init__  s&    8 	 r   c                    UR                  5       nUR                  U5        U R                  X`R                  5      nX@R	                  U5      -   n[
        R                  " U R                  5      * n[
        R                  " [
        R                  " U5      [
        R                  " U5      * /[
        R                  " U5      [
        R                  " U5      //5      n	UR                  U R                  5      n
UR                  U5      nUR                  SS9nU GH  nUSS2S4   nUSS2S4   nUR                  S:  a  M(  [
        R                   " USS USS -
  USS USS -
  5      n[
        R"                  " S/[
        R$                  " U5      45      nUS   n['        [
        R(                  " UU
-  5      5      S-
  n[
        R*                  " U
S-  UU
S-  -
  U5      n[
        R,                  " UUU5      n[
        R,                  " UUU5      nU R                  S	-  n[
        R,                  " UU-   UU5      U-
  U-  n[
        R,                  " UU-   UU5      U-
  U-  n[
        R                   " UU5      nUS:H  nS
UU'   [
        R                  " UU-  UU-  /5      R.                  n[
        R                  " SS/5      R.                  UU'   [
        R0                  " UU	5      U R2                  -  U
-  nUUSS2S4   -   nUUSS2S4   -   n[
        R4                  " SU-  S4UR6                  S9n UU SSS2S4'   UU SSS2S4'   UU SSS2S4'   UU SSS2S4'   [
        R8                  " [:        R<                  [:        R>                  /U5      n![;        U U!5      n"URA                  UU"URC                  5       U-   U5        GM     URE                  5         g)r   F)closed_onlyNr   r[   r   r8   gMbP?r   )dtype)#rN   r   r-   r   r   npradiansr   arraycossinr   r   transform_pathto_polygonssizehypotconcatenatecumsumintceillinspaceinterpTdotr   emptyr   tiler   MOVETOLINETOr3   invertedr   )#r   r   r(   r4   r5   r6   r   transthetatrans_matrix
spacing_px	transpathpolyspxydsrl   s_totalnums_tickx_ticky_tickdelta_sur+   nmaskuvdxyx_endy_endxytcodeshs#                                      r   r3   TickedStroke.draw_path  s    ooBooc88,//99DKK((xx"&&-"&&-!@"$&&-!?!A B ..t}}=
 ))%0	 %%%%8A!Q$A!Q$A vvz !AB%!CR&.!AB%!CR&.9B ryy}56AeGbggg
234q8C[[AwA/EsKF YYvq!,FYYvq!,F mmd*G6G+Q2V;wFA6G+Q2V;wFA AA6DAdG1q5!a%.)++BxxA'))BtH &&\*T\\9JFC SAY&ESAY&E ((AGQ<v||<C!C1aL C1aL!C1aL C1aL GGT[[$++6<E S% AsAv'85'@'Js v 	r   )r   r   r   r   )r:   r;   r<   r=   r>   r   sqrtr   r3   r?   rr   rs   s   @r   r   r   v  s.     %T"''!*!FS Sr   r   )r>   matplotlib.backend_basesr   
matplotlibr   r   r   r   r   r   matplotlib.pathr   numpyr   r	   r1   ru   r   r   
withStroker   withSimplePatchShadowr   r   r   withTickedStroker    r   r   <module>r     s    2 ( * 0   3> 3>lP- P-f < , #7
>* >B .;LM 6) 6r"( ">F% FR )lC r   