o
    h                     @   sB  d dl Z d dlZd dlmZ d dlmZ d dlm	Z
 d dlmZ d dlmZ d dlmZ d dlmZ edgddd	d
 Zedgdde  dkrJd ndddd Zedge  dkr]d ndddd Zedgdd Zdd Zdd Zedgddd d!d" Zed#gdd$gd%d&d'd( Zed)gddd*d+ Zd,d- ZdS ).    N)image_comparison)Path)RendererBase)PathEffectRendererpatheffect1T)remove_textc                  C   s   t  } | ddgddgg | jdddtdddd	d
dtjdddgd}|jtj	dddt
 g tjdddg}| jdd|d d S )N         test)      ?r   )        r   z->angle3)
arrowstyleconnectionstylelw   centerw	linewidth
foreground)
arrowpropssizehapath_effects   T-)	linestyler   )pltsubplotimshowannotatedictr   
withStrokearrow_patchset_path_effectsStrokeNormalgrid)ax1txtpe r-   u/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/matplotlib/tests/test_patheffects.pytest_patheffect1   s$   
r/   patheffect2mpl20x86_64gQ?)r   styletolc                  C   sz   t  } tdd}| j|dd | j|dd}|jtj	ddd	gd
 | j
|ddd}t j|tj	ddd	gd
 d S )N   )r   r   nearest)interpolationkcolorsr
   r   r   r   z%2.0fT)fmtuse_clabeltext)r   r    nparangereshaper!   contoursetr   r$   clabelsetp)ax2arrcntrclblsr-   r-   r.   test_patheffect2    s   
rI   patheffect3g~jt?)r4   c                  C   s  t jg dddd\} | t t g t jdtjdddgd	 t j| gd
gddd}|j	t
 g t jdddddddd}tjdddtj
dddg}|| | | tjddddtjddd d!g}t  jd"d#d$d%d&d'd(}|| d S ))N)r   r
   r      r
   zo-brK   )r   ztesting$^{123}$r   rr   r;   z
Line 1$^2$Tz
upper left)fancyboxlocr	   r
   z	Drop testwhitezcircle,pad=0.1red)boxstylecolor)rR   bboxg      @r8   )   blue)shadow_rgbFace)rK   xxxxgray)offsethatch	facecolorblackg?)	edgecolorr]   r   g{Gz?g?zHatch shadowK   i  r   )fontsizeweightva)r   plotr&   r   SimpleLineShadowr(   titler$   legendlegendPatchwithSimplePatchShadowtextr'   get_bbox_patchPathPatchEffectgcf)p1legrj   r,   tr-   r-   r.   test_patheffect30   s:   

rq   zstroked_text.pngc               
   C   s   g d} d}t d}t| D ]&\}}|jdd|d  |dd|d	d
d}|tj|d ddt g q|dd |	dd |
d d S )N)zA B C D E F G H I J K LzM N O P Q R S T U V WzX Y Z a b c d e f g h i jzk l m n o p q r s t u vzw x y z 0123456789z!@#$%^&*()-=_+[]\;'z,./{}|:"<>?2   )r   r   r   r   g{Gz?g?gp=
ף?leftr   rO   )r   rc   r   rR   )xysfontdict
   r^   r   r   r   off)r   axes	enumeraterj   r&   r   r'   r(   set_xlimset_ylimaxis)text_chunks	font_sizeaxichunkrj   r-   r-   r.   test_patheffects_stroked_textM   s"   	
r   c                  C   sh   t jdd} t td\}|t t g | j	 }t
| |}|d|dks2J d S )N   )dpirx      )r   figurerd   ranger&   r   re   r(   canvasget_rendererr   get_path_effectspoints_to_pixels)figrn   rendererpe_rendererr-   r-   r.    test_PathEffect_points_to_pixelsi   s   

r   c                  C   s   t jdd} | jdksJ d S )N)rK   r   )r[   )r   SimplePatchShadow_offset)r,   r-   r-   r.   test_SimplePatchShadow_offsetv   s   r   
collectiongQ?)r4   r3   c                  C   s   t t dddt ddd\} }t | t | }t|}|jtj	ddd	d
tj
ddgd tj|ddD ]}|tjdddg |dddd q:d S )Nr   rx   r   r   d   r^   none   )r_   r]   r   )r   r;   rO   r9   r8   r
   )r   r   sawtoothrV   )rQ   r]   r_   )r>   meshgridlinspacesincosr   rA   rB   r   rl   r'   rC   r&   r$   set_bbox)rt   ru   datacsrj   r-   r-   r.   test_collection{   s   $




r   tickedstrokepngg)\(?)r   
extensionsr4   c               	   C   s  t jdddd\} \}}}t }tj|ddtjdddd	gd
}|| |	d |
dd |dd |jddgddgdtjdddgd d}tdd|}dt|d  d }|j||dt gd |  d}d}	tdd|}
tdd|	}t|
|\}}d| | d  }|d|  d  }d|d  | }|j|||dgd d!}|jtjdd"gd# |j|||dgd$d!}|jtjd%dd&gd# |j|||dgd'd!}|jtjdd(gd# |
dd |dd d S ))Nr   r
   )r   rK   )figsizer   r	   irx   )anglespacinglength)r]   r   r   equalr          )r   r   )labelr   e   r   r   g333333?   g?i   gMbP?g      @g      @rK   g?rU   )r8   r9   )r   r;   )rL   <   )r   r   )b)r   )r   subplotsr   unit_circlepatches	PathPatchr   withTickedStroke	add_patchr~   r|   r}   rd   r>   r   r   rg   r   rA   rB   )r   r*   rE   ax3pathpatchnxrt   ru   nyxvecyvecx1x2g1g2g3cg1cg2cg3r-   r-   r.   test_tickedstroke   sJ   


r   zspaces_and_newlines.pngc               	   C   sl   t  } d}d}| jdd|dddddid	}| jdd
|dddddid	}|t g |t g d S )Nz	         z
Newline also causes problemsg      ?g      ?r   r   rR   salmon)r   rc   r   rS   g      ?thistle)r   r    rj   r&   r   r(   )r   s1s2text1text2r-   r-   r.   $test_patheffects_spaces_and_newlines   s   r   c                  C   sJ   G dd dt } tt g|  }|ddksJ |ddks#J d S )Nc                       s.   e Zd Z fddZdddZdd Z  ZS )	zLtest_patheffects_overridden_methods_open_close_group.<locals>.CustomRendererc                    s   t    d S N)super__init__)self	__class__r-   r.   r      s   zUtest_patheffects_overridden_methods_open_close_group.<locals>.CustomRenderer.__init__Nc                 S      dS )Nopen_group overriddenr-   )r   rv   gidr-   r-   r.   
open_group      zWtest_patheffects_overridden_methods_open_close_group.<locals>.CustomRenderer.open_groupc                 S   r   )Nclose_group overriddenr-   )r   rv   r-   r-   r.   close_group   r   zXtest_patheffects_overridden_methods_open_close_group.<locals>.CustomRenderer.close_groupr   )__name__
__module____qualname__r   r   r   __classcell__r-   r-   r   r.   CustomRenderer   s    
r   rv   r   r   )r   r   r   r(   r   r   )r   r   r-   r-   r.   4test_patheffects_overridden_methods_open_close_group   s   
r   )platformnumpyr>   matplotlib.testing.decoratorsr   matplotlib.pyplotpyplotr   matplotlib.patheffectspatheffectsr   matplotlib.pathr   matplotlib.patchesr   matplotlib.backend_basesr   r   r/   machinerI   rq   r   r   r   r   r   r   r   r-   r-   r-   r.   <module>   s@    






2
