U
    Ñtœd¨  ã                   @   sD   d dl mZ d dlmZ ddlmZ dZeƒ \ZZG dd„ dƒZ	dS )	é    )Úcalculate_corner_radii)Úconsecutive_pairsé   )Úfind_matplotlib)ÚMatplotlibPolygonDrawerc                   @   s"   e Zd ZdZdd„ Zddd„ZdS )	r   aO  Class that is used to draw polygons in matplotlib.

    The corner points of the polygon can be set by the C{points}
    property of the drawer, or passed at construction time. Most
    drawing methods in this class also have an extra C{points}
    argument that can be used to override the set of points in the
    C{points} property.c                 C   s
   || _ dS )z�Constructs a new polygon drawer that draws on the given
        Matplotlib axes.

        @param  ax: the matplotlib Axes to draw on
        N)Úcontext)ÚselfÚax© r
   úZ/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/matplotlib/polygon.pyÚ__init__   s    z MatplotlibPolygonDrawer.__init__r   c                 K   sV  t |ƒdk rdS | j}|dkr8tjj|f|Ž}| |¡ t||ƒ}g }g }| |d  |d |d ¡¡ | tj	j
j¡ |d }	tt|dƒƒD ]š\}
\}}||
 }| | |	|¡¡ | tj	j
j¡ | |	|d ¡}| ||d ¡}| |¡ | |¡ | | |||
 ¡¡ | tj	j
jgd ¡ |}	qŽtjjtj	j
||dd�f|Ž}| |¡ dS )a¨  Draws a polygon to the associated axes.

        @param points: the coordinates of the corners of the polygon,
          in clockwise or counter-clockwise order, or C{None} if we are
          about to use the C{points} property of the class.
        @param corner_radius: if zero, an ordinary polygon will be drawn.
          If positive, the corners of the polygon will be rounded with
          the given radius.
        é   Nr   éÿÿÿÿTé   )ÚcodesÚclosed)Úlenr   ÚmplZpatchesZPolygonZ	add_patchr   ÚappendZtowardsÚpathÚPathZMOVETOÚ	enumerater   ZLINETOÚextendZCURVE4Z	PathPatch)r   ZpointsZcorner_radiusÚkwdsr	   ÚstrokeZcorner_radiir   r   ÚuÚidxÚvÚwZradiusZaux1Zaux2r
   r
   r   Údraw   s:    





ÿþzMatplotlibPolygonDrawer.drawN)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r
   r
   r
   r   r      s   r   N)
Zigraph.drawing.utilsr   Zigraph.utilsr   Úutilsr   Ú__all__r   Zpltr   r
   r
   r
   r   Ú<module>   s
   
