
    BPc/                         d Z ddlZddlmZmZ ddlZddlmZ ddl	m
Z
mZmZmZmZ ddlmZmZ  G d dej                  Zed	k    r e                                             dS dS )
z!Join paths with lines or polygons    N)ListUnion)inkex_gettext)	ZoneClose	zoneCloseLineMovemove)PathGroupBuilderPathBuilderc                   `    e Zd ZdZd Zed             Zed             Zed             Zd Z	dS )Extrudea  This effect draws lines between each nth node of each selected path.
    It can be chosen whether these regions are filled and whether the fill uses rectangles
    or copies of the path segments.
    The lines will be inserted between the two elements.
    c                     |                     d           |                     dddg dd           |                     dd	d
t          j        d           d S )Nz--tabz-mz--modelines)r   polygonssnugzBJoin paths with lines, polygons or copies of the segments ("snug"))defaultchoiceshelpz-sz
--subpathsTzIf true, connecting lines will be inserted as subpaths of a single path.
                        If false, they will be inserted in newly created group. 
                        Only applies to mode=lines)r   typer   )add_argumentinkexBoolean)selfparss     )/usr/share/inkscape/extensions/extrude.pyadd_argumentszExtrude.add_arguments'   s    '"""111U 	 	
 	
 	
 	6 	 	
 	
 	
 	
 	
    c                     t          |j        t          t          f          sAt          |j        t          t          f          s" | j        |j           | j        |j          d S d S d S N)
isinstancecommandr   r   Move_to	end_pointLine_to)managercom1com2s      r   _handle_lineszExtrude._handle_lines:   st     t|i%;<<	-$,I(>??	-
 GOT^,,GOT^,,,,	- 	- 	- 	-r   c                     t          |j        t          t          f          sWt          |j        t          t          f          s8 | j        |j          |j        |j        |j        |j        fD ]} | j        |  d S d S d S r    )r!   r"   r	   r
   r#   previous_end_pointr$   r%   )r&   r'   r(   points       r   _handle_polygonszExtrude._handle_polygonsD   s     t|dD\22	($,t55	(
 GOT455''	 ( (  '''	( 	( 	( 	(( (r   c                    t          |j        t          t          f          st          |j        t          t          f          s | j        |j          |j        }|                                }d}t          |t          t          f          r/t          |j
         }|j                            |j                  rd}|r7|                     |t          |j         |t                      g           d S d S d S d S )NTF)r!   r"   r	   r
   r#   r+   reverser   r   r   first_pointis_closer$   add)r&   r'   r(   com1rcom2rdoflags         r   _handle_snugzExtrude._handle_snugT   s     t|dD\22	P$,t55	P
 GOT455LELLNNEF%)Y!788 #d./*33DNCC #"F PUD$.$95)++NOOOOO	P 	P 	P 	PP Pr   c                    g }| j         j                                                            t          j                  D ]E}t          |t          j                  r|                                 |	                    |           Ft          |          dk     r!t	          j        t          d                    | j        j                                        dk    }| j        j        o|}|r| j        n/| j        j                                        dk    r| j        n| j        }|rddddd	}n	dd
ddddd}t)          j        |d          D ]\  }}|rt-          |          nt/          |          }	t1          |j                                        |j                                                  D ]&\  }
} ||	|
|           |	                                 '|	                    |           d S )N   zNeed at least 2 paths selectedr   r   nonez#000000   1px)fillstrokestroke-opacitystroke-widthg333333?g333333?round)r<   zfill-opacityr=   r>   r?   zstroke-linejoin)svg	selectionrendering_orderfilterr   ShapeElementr!   PathElementapply_transformappendlenAbortExtension_optionsmodelowersubpathsr)   r-   r6   	itertoolscombinationsr   r   zippathproxy_iterator	terminateappend_next)r   pathsnoder   rO   rM   stylepa1pa2r&   r'   r(   s               r   effectzExtrude.effectg   s   )+H&6688??@RSS 	 	D$ 122 '$$&&&LLu::>>&q)I'J'JKKK!''))W4<(2U D <$**,,
:: %%& 	  	#"# %	 EE " ##"% %#* E ".ua88 	% 	%HC,4Qk%(((:J5:Q:QG!#("9"9";";SX=T=T=V=VWW $ $
dWdD)))!!####$$$$	% 	%r   N)
__name__
__module____qualname____doc__r   staticmethodr)   r-   r6   r\    r   r   r   r       s         
 
 
& - - \- ( ( \( P P \P$+% +% +% +% +%r   r   __main__)r`   rP   typingr   r   r   inkex.localizationr   rK   inkex.pathsr   r   r   r	   r
   inkex.turtler   r   EffectExtensionr   r]   runrb   r   r   <module>rj      s   ( ( '              1 1 1 1 1 1 > > > > > > > > > > > > > > 6 6 6 6 6 6 6 6r% r% r% r% r%e# r% r% r%j zGIIMMOOOOO r   