U
    Ñtœdï  ã                   @   s<   d dl mZ d dlmZ ddlmZ dZG dd„ deƒZdS )	é    )Úcalculate_corner_radii)Úconsecutive_pairsé   )ÚAbstractCairoDrawer)ÚCairoPolygonDrawerc                       s4   e Zd ZdZd
‡ fdd„	Zddd„Zdd	„ Z‡  ZS )r   aJ  Class that is used to draw polygons in Cairo.

    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.©r   r   c                    s   t ƒ  ||¡ dS )zÎConstructs a new polygon drawer that draws on the given
        Cairo context.

        @param  context: the Cairo context to draw on
        @param  bbox:    ignored, leave it at its default value
        N)ÚsuperÚ__init__)ÚselfÚcontextZbbox©Ú	__class__© úU/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/cairo/polygon.pyr	      s    zCairoPolygonDrawer.__init__r   c                 C   s  | j  ¡  t|ƒdk rdS | j }|dkrN|j|d Ž  |D ]}|j|Ž  q:dS t||ƒ}|j|d  |d |d ¡Ž  |d }tt|dƒƒD ]t\}\}}	|| }
|j| ||
¡Ž  | ||
d ¡}| |	|
d ¡}|j	|j
|j|j
|jf| |	|| ¡žŽ  |}qŒdS )a…  Sets up a Cairo path for the outline of a polygon on the given
        Cairo context.

        @param points: the coordinates of the corners of the polygon,
          in clockwise or counter-clockwise order.
        @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)r   Únew_pathÚlenÚmove_toZline_tor   ZtowardsÚ	enumerater   Zcurve_toÚxÚy)r
   ÚpointsZcorner_radiusÚctxÚpointZcorner_radiiÚuÚidxÚvÚwZradiusZaux1Zaux2r   r   r   Ú	draw_path   s4    



   ÿÿzCairoPolygonDrawer.draw_pathc                 C   s   |   |¡ | j ¡  dS )zÃDraws the polygon using the current stroke of the Cairo context.

        @param points: the coordinates of the corners of the polygon,
          in clockwise or counter-clockwise order.
        N)r   r   Ústroke)r
   r   r   r   r   ÚdrawN   s    
zCairoPolygonDrawer.draw)r   )r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r!   Ú__classcell__r   r   r   r   r   	   s   	
3r   N)Zigraph.drawing.utilsr   Zigraph.utilsr   Úbaser   Ú__all__r   r   r   r   r   Ú<module>   s   