U
    td                     @   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 )zConstructs 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  |}	qt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
   
