rL iG6dZddlmZddlmZddlmZddlmZ ddl m Z ddl Z Gdd ZGd d eZGd d eZdZGddeZeeZGddeZeeZGddeZGddeZGddeZeeZy)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,eZdZdZddZdZdZddZy) AbstractPathEffectz A base class for path effects. Subclasses should override the ``draw_path`` method to add effect functionality. c||_y)z Parameters ---------- offset : (float, float), default: (0, 0) The (x, y) offset to apply to the path, measured in points. N)_offset)selfoffsets \/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/matplotlib/patheffects.py__init__zAbstractPathEffect.__init__s  ctjjt|j|j S)z(Apply the offset to the given transform.) mtransformsAffine2D translatemappoints_to_pixelsr )r renderers r_offset_transformz$AbstractPathEffect._offset_transform"s4/{##%// **DLL 9; ;rc|j}|jdd}|r|jdi||jD]6\}}t |d|zd}t |st d|||8|S)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*. dashesNset_zUnknown property )copypop set_dashesitemsgetattrcallableAttributeError)r gc new_gc_dictrkv set_methods r _update_gczAbstractPathEffect._update_gc's"&&( 40  BMM #F #%%' DAq VaZ6JJ'$'8%<== qM    rNcbt|tr |j}|j||||S)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. ) isinstancePathEffectRenderer _renderer draw_path)r rr$tpathaffinergbFaces rr.zAbstractPathEffect.draw_path;s1 h 2 3))H!!"eVW==r))r2N)__name__ __module__ __qualname____doc__rrr)r.rrrr r s; ( >rr cTeZdZdZdZdZdZd dZfdZfdZ d dZ d Z xZ S) r,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 ||_||_y)z Parameters ---------- path_effects : iterable of :class:`AbstractPathEffect` The path effects which this renderer represents. renderer : `~matplotlib.backend_bases.RendererBase` subclass N) _path_effectsr-)r path_effectsrs rrzPathEffectRenderer.__init__Ts*!rc:|j||jSr3) __class__r-)r r;s rcopy_with_path_effectz(PathEffectRenderer.copy_with_path_effect`s~~lDNN;;rcb|dvrt|j|Stj||S)N)flipyget_canvas_width_heightnew_gcr _text2pathheightwidth)r!r-object__getattribute__)r names rrGz#PathEffectRenderer.__getattribute__cs5 I I4>>40 0**46 6rcd|jD]!}|j|j||||#yr3)r:r.r-)r r$r/r0r1 path_effects rr.zPathEffectRenderer.draw_pathjs4-- +K  ! !$.."eV") + +rct|jdk(rt | ||||g|i|S|jD]-}|j |g}|j||||g|i|/yN)lenr:super draw_markersr>) r r$ marker_path marker_transpathargskwargsrJrr=s rrPzPathEffectRenderer.draw_markersos t!! "a '7'Kt9)-9179 9 -- 3K11;-@H "H ! !"k< 3#' 3+1 3  3rct|jdk(rt| |||g|i|S|jD],}|j |g}|j|||g|i|.yrL)rNr:rOdraw_path_collectionr>) r r$master_transformpathsrTrUrJrr=s rrWz'PathEffectRenderer.draw_path_collections t!! "a '7/4DeA15A9?A A -- ;K11;-@H *H ) )".> ;+/ ;39 ;  ;rc:|jj||Sr3)r- open_group)r sgids rr[zPathEffectRenderer.open_groups~~((C00rc8|jj|Sr3)r- close_group)r r\s rr_zPathEffectRenderer.close_groups~~))!,,rr3) r4r5r6r7rr>rGr.rPrWr[r_ __classcell__r=s@rr,r,Gs0  "<7+ 3$;$1-rr,ceZdZdZy)Normalz The "identity" PathEffect. The Normal PathEffect's sole purpose is to draw the original artist with no special path effect. N)r4r5r6r7rrrrcrcsrrccGdd|}d|j|_d|j|_d|jd|jd|jd|_|jj|j_|S)zO Create a PathEffect class combining *effect_class* and a normal draw. ceZdZfdZxZS))_subclass_with_normal..withEffectcTt|||||||j||||yr3)rOr.)r rr$r/r0r1r=s rr.z3_subclass_with_normal..withEffect.draw_paths, G hE67 C   r5&' :r)r4r5r6r.r`ras@r withEffectrfs  ; ;rrhwithz* 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()]) )r4r6r7r.) effect_classrhs r_subclass_with_normalrks ;\; !!6!6 78J $\%:%:$;#BD =E  rc|j}|j||j:|xsddd\}}} ||jz||jz| |jzf} n |j} |j d|j |j |jd|j||j}|j||||j|z| |jy) Overrides the standard draw_path to add the shadow offset and necessary color changes for the shadow. N?rrnoner) rBrsr}rset_foreground set_alphar set_linewidthr)ror.rrt r rr$r/r0r1rurgbrs rr.zSimplePatchShadow.draw_paths oo B    '.,3GAq!$))mQ]A MJN!11N 6" dkk" !ooc488, !7!7!AA   r)NNr|rxras@rrzrzs-%,0"Hrrzc.eZdZdZ dfd ZdZxZS)SimpleLineShadowzA simple shadow via a line.c t|||||_ntj||_||_||_||_y)a 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)rOr _shadow_colorr~rrrro)r r shadow_colorrrrUr=s rrzSimpleLineShadow.__init__!sF(   !-D !(!>D   rc|j}|j||jH|jxsddd\}}} ||jz||jz| |jzf} n |j} |j | |j |j|j||j}|j||||j|z|jy)rNrr) rBrsrget_foregroundrrrrr)ror.rrtrs rr.zSimpleLineShadow.draw_path?s oo B    %))+;|Ra@GAq!$))mQ]A MJN!//N >* dkk"ooc488, !7!7!AA C r)rr&r|r|rxras@rrrs%%25<rrc*eZdZdZdfd ZdZxZS)PathPatchEffectza Draws a `.PathPatch` instance whose Path comes from the original PathEffect artist. c \t||tjgfi||_y)a 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)rOrmpatches PathPatchpatchrps rrzPathPatchEffect.__init__]s, '''5f5 rc||j_|jj||j|z|jj |j |j }|r3|jj |jj||jj|yr3) r_path set_transformr set_clip_boxget_clip_rectangle get_clip_path set_clip_pathdraw)r rr$r/r0r1 clip_paths rr.zPathPatchEffect.draw_pathls     $*@*@*J!JK  5 5 78$$& 113; $DJJ $ $i 0 !rrvrxras@rrrWs 6"rrcReZdZdZdddej dffd ZdZxZS) TickedStrokea 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. rwg$@gF@rc \t||||_||_||_||_y)a% 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)rOr_spacing_angle_lengthro)r r spacinganglelengthrUr=s rrzTickedStroke.__init__s.8     rc|j}|j||j||j}||j |z}t j |j }t jt j|t j| gt j|t j|gg} |j|j} |j|} | jd} | D]} | dddf}| dddf}|jdkr&t j |dd|ddz |dd|ddz }t j"dgt j$|f}|d}t't j(|| z dz }t j*| dz || dz z |}t j,|||}t j,|||}|jd z}t j,||z|||z |z }t j,||z|||z |z }t j ||}|dk(}d ||<t j||z ||z gj.}t jddgj.||<t j0|| |j2z| z}||dddfz}||dddfz}t j4d|zdf|j6 } || ddddf<|| ddddf<|| ddddf<|| ddddf<t j8t:j<t:j>g|}!t;| |!}"|jA||"|jC|z||jEy) rrF) closed_onlyNrrMrr2gMbP?r)dtype)#rBrsr)rornpradiansrarraycossinrrtransform_path to_polygonssizehypot concatenatecumsumintceillinspaceinterpTdotremptyrtilerMOVETOLINETOr.invertedrt)#r rr$r/r0r1rutranstheta trans_matrix spacing_px transpathpolyspxydsr\s_totalnums_tickx_ticky_tickdelta_sur'nmaskuvdxyx_endy_endxytcodeshs# rr.zTickedStroke.draw_pathsoo Booc488,//99DKK((xx"&&-"&&-!@"$&&-!?!AB ..t}}= ))%0 %%%%89 KA!Q$A!Q$Avvz!AB%!CR&.!AB%!CR&.9Bryy}56AeGbggg 234q8C[[AwA/EsKFYYvq!,FYYvq!,Fmmd*G6G+Q2V;wFA6G+Q2V;wFAAA6DAdG1q5!a%.)++BxxA'))BtH&&\*T\\9JFCSAY&ESAY&E((AGQrs2(*0 3>3>lP-P-f < ,# 7 >*>B.;LM6)6r"(">F%FR)lCr