U
    Ñtœd<  ã                   @   s(   d Z ddlmZ dZG dd„ deƒZdS )zGThis module provides implementation for a Cairo-specific palette draweré    )ÚAbstractCairoDrawer)ÚCairoPaletteDrawerc                       s(   e Zd ZdZ‡ fdd„Zdd„ Z‡  ZS )r   z(Default Cairo drawer object for palettesc                    s   t ƒ j|dd� dS )z�Constructs the vertex drawer and associates it to the given
        palette.

        @param context: the context on which we will draw
        N)Úbbox)ÚsuperÚ__init__)ÚselfÚcontext©Ú	__class__© úU/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/cairo/palette.pyr      s    zCairoPaletteDrawer.__init__c              
   K   sÐ   ddl m} ddlm} | j}|| dd¡ƒ}ttt| ƒƒƒ}|dkrN| 	¡  |dkrb||gƒ}n|dd	„ |D ƒƒ}| 
d
d¡ }	| _|	dkr–tdƒ‚t| dd¡ƒ}
t| dd¡ƒ}|jd||	| dd||
d�S )ÚTODOr   )ÚMatrix)Ústr_to_orientationÚorientationÚlr)ÚrlZbt)r   r   c                 S   s   g | ]
}|g‘qS r   r   )Ú.0Úir   r   r   Ú
<listcomp>"   s     z+CairoPaletteDrawer.draw.<locals>.<listcomp>r   Nz bbox is required for Cairo plotsÚborder_widthg      ð?Ú
grid_widthg        ZcairoÚpaletteF)r   r   ÚstyleZsquarer   r   )Zigraph.datatypesr   Zigraph.drawing.utilsr   r   ÚgetÚlistÚrangeÚlenÚreverseÚpopr   Ú
ValueErrorÚfloatZ__plot__)r   r   Úkwdsr   r   r   r   ÚindicesÚmatrixr   r   r   r   r   r   Údraw   s2    øzCairoPaletteDrawer.draw)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r%   Ú__classcell__r   r   r	   r   r      s   r   N)r)   Zigraph.drawing.cairo.baser   Ú__all__r   r   r   r   r   Ú<module>   s   