U
    Ñtœdœ  ã                   @   sD   d dl mZ d dlmZ ddlmZmZ dZeƒ ZG dd„ dƒZ	dS )	é    )Úcalculate_corner_radii)Úconsecutive_pairsé   )Úfind_plotlyÚformat_path_step)ÚPlotlyPolygonDrawerc                   @   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  fig: the plotly Figure to draw on
        N)Úcontext)ÚselfÚfig© r   úV/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/plotly/polygon.pyÚ__init__   s    zPlotlyPolygonDrawer.__init__r   c                 K   s‚  t |ƒdk rdS | j}|dkrˆdd„ |D ƒ|d d g }dd„ |D ƒ|d d g }| dd	¡|d< tjjf ||d
œ|—Ž}| |¡ t||ƒ}g }	|	 t	d|d  
|d |d ¡gƒ¡ |d }
tt|dƒƒD ]t\}\}}|| }|	 t	d| 
|
|¡gƒ¡ | 
|
|d ¡}| 
||d ¡}|	 t	d||| 
||| ¡gƒ¡ |}
qÒd |	¡ d¡d }	tf d|	dœ|—Ž}|j|gd 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   c                 S   s   g | ]}|d  ‘qS )r   r   ©Ú.0Úpr   r   r   Ú
<listcomp>.   s     z,PlotlyPolygonDrawer.draw.<locals>.<listcomp>c                 S   s   g | ]}|d  ‘qS )r   r   r   r   r   r   r   /   s     r   ÚmodeÚline)ÚxÚyÚMéÿÿÿÿTÚLÚCÚ ú z ZÚpath)Útyper   )Zshapes)Úlenr   ÚgetÚplotlyZgraph_objectsZScatterZ	add_tracer   Úappendr   ZtowardsÚ	enumerater   ÚjoinÚstripÚdictZupdate_layout)r	   ZpointsZcorner_radiusÚkwdsr
   r   r   ÚstrokeZcorner_radiir   ÚuÚidxÚvÚwZradiusZaux1Zaux2r   r   r   Údraw   sd    
þý


þÿ
þÿþÿþýÿzPlotlyPolygonDrawer.drawN)r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r-   r   r   r   r   r      s   r   N)
Zigraph.drawing.utilsr   Zigraph.utilsr   Úutilsr   r   Ú__all__r!   r   r   r   r   r   Ú<module>   s
   