U
    tdz                     @   sP   d dl mZmZ d dlmZ dZdZedddZdd	 ZdddZ	dd Z
dS )    )
FakeModulePoint)Any)find_plotlyzrestructuredtext en)returnc                  C   s.   zddl } W n tk
r(   td} Y nX | S )ztTries to import the ``plotly`` Python module if it is installed.
    Returns a fake module if everything fails.
    r   Nz4You need to install plotly to use this functionality)plotlyImportErrorr   )r    r	   T/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/igraph/drawing/plotly/utils.pyr      s
    r   c                 C   sX   t |d ttfr|g}n|}|  }|D ]*}|d |d  }}|d| d| 7 }q(|S )z"Format step in SVG path for plotlyr       ,)
isinstancefloatint)codeZpoint_or_pointsZpointssteppointxyr	   r	   r
   format_path_step   s    r   d   Fc                    s   ddl | \d|   fddt D }fdd|D }fdd|D }	d|d  d	|	d  }
td
t|D ] }|
d||  d	|	|  7 }
q|r|
d7 }
|
S )zlApproximation of an SVG-style arc

    NOTE: plotly does not currently support the native SVG "A/a" commandsr   Ng      ?c                    s    g | ]}|  d    qS )r   r	   .0i)Ndttheta1r	   r
   
<listcomp>,   s     zformat_arc.<locals>.<listcomp>c                    s   g | ]}  |  qS r	   )cosr   )mathradius_xxcr	   r
   r   -   s     c                    s   g | ]}  |  qS r	   )sinr   )r    radius_yycr	   r
   r   .   s     zM z, r   Lz Z)r    rangelen)centerr!   r$   r   Ztheta2r   closedtr   r   pathkr	   )r   r   r    r!   r$   r   r"   r%   r
   
format_arc$   s    r.   c              	   C   s   t | tr| S t | tr2| dkr(| d } | gd } td| d  }td| d  }td| d  }t| dkrtd| d  }nd}d| d| d| d| d		}|S )
z+Format colors in a way understood by plotlyr   g     o@      r      zrgba(r   ))r   strr   r   r(   )colorrgbaZcolstrr	   r	   r
   format_rgba7   s    


r9   N)r   F)Zigraph.drawing.utilsr   r   typingr   __all____docformat__r   r   r.   r9   r	   r	   r	   r
   <module>   s   
