U
    td                     @   sj   d 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ZG d	d
 d
ee
ZG dd deZdS )zThis module provides implementations of Cairo-specific vertex drawers, i.e.
drawers that the Cairo graph drawer will use to draw vertices.
    )pi)AbstractVertexDrawerAttributeCollectorBase)ShapeDrawerDirectory   )AbstractCairoDrawer)AbstractCairoVertexDrawerCairoVertexDrawerc                   @   s   e Zd ZdZdd ZdS )r	   zCAbstract base class for vertex drawers that draw on a Cairo canvas.c                 C   s    t | || t| || dS )a  Constructs the vertex drawer and associates it to the given
        Cairo context and the given L{BoundingBox}.

        @param context: the context on which we will draw
        @param bbox:    the bounding box within which we will draw.
                        Can be anything accepted by the constructor
                        of L{BoundingBox} (i.e., a 2-tuple, a 4-tuple
                        or a L{BoundingBox} object).
        @param palette: the palette that can be used to map integer
                        color indices to colors when drawing vertices
        @param layout:  the layout of the vertices in the graph being drawn
        N)r   __init__r   selfcontextZbboxpalettelayout r   T/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/cairo/vertex.pyr      s    z"AbstractCairoVertexDrawer.__init__N)__name__
__module____qualname____doc__r   r   r   r   r   r	      s   r	   c                       s0   e Zd ZdZ fddZdd Zdd Z  ZS )r
   z3The default vertex drawer implementation of igraph.c                    s    t  |||| |  | _d S )N)superr    _construct_visual_vertex_builderVisualVertexBuilderr   	__class__r   r   r   '   s    zCairoVertexDrawer.__init__c                    s   G  fdddt }|S )Nc                       sz   e Zd ZdZdZd jjfZd jjfZdZ	dZ
e d ZdZd jjfZd	Zd
Ze jjdZdejfZdZdZdZdS )zOCairoVertexDrawer._construct_visual_vertex_builder.<locals>.VisualVertexBuilderz7Collects some visual properties of a vertex for drawingZvertex_redblackg      ?N   g        z
sans-serifg      ,@)funccircleg      4@)r   r   r   r   Z_kwds_prefixr   getcolorframe_colorframe_widthlabelr   Zlabel_angleZ
label_distZlabel_colorZfontZ
label_sizedictr   __getitem__positionr   Zresolve_defaultshapesizewidthheightr   r   r   r   r   ,   s    

r   r   )r   r   r   r-   r   r   +   s    z2CairoVertexDrawer._construct_visual_vertex_builderc                 C   s   | j }|jd k	r|jn|j}|jd k	r,|jn|j}|j||d |d || |j|j  |  |j|j	  |
|j |  d S )Nr   r   )r   r+   r*   r,   r)   Z	draw_pathZset_source_rgbar"   Zfill_preserver#   Zset_line_widthr$   stroke)r   Zvisual_vertexZvertexZcoordsr   r+   r,   r   r   r   drawA   s    zCairoVertexDrawer.draw)r   r   r   r   r   r   r/   __classcell__r   r   r   r   r
   $   s   r
   N)r   mathr   Zigraph.drawing.baseclassesr   Zigraph.drawing.metamagicr   Zigraph.drawing.shapesr   baser   __all__r	   r
   r   r   r   r   <module>   s   