HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/share/inkscape/extensions/pathmodifier.pyo
�
��Yc@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Td�Z
dejfd��YZdefd��YZ
dS(	s
Copyright (C) 2006 Jean-Francois Barraud, barraud@math.univ-lille1.fr

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
barraud@math.univ-lille1.fr

This code defines a basic class (PathModifier) of effects whose purpose is
to somehow deform given objects: one common tasks for all such effect is to
convert shapes, groups, clones to paths. The class has several functions to
make this (more or less!) easy.
As an exemple, a second class (Diffeo) is derived from it,
to implement deformations of the form X=f(x,y), Y=g(x,y)...

TODO: Several handy functions are defined, that might in fact be of general
interest and that should be shipped out in separate files...
i����N(t*cCsug}|jd�}||kr1|j|�nx=|D]5}t|�t|�krZPn|t||�7}q8W|S(Ntid(tgettappendtlentzSort(tinNodetidListt
sortedListttheidtchild((s./usr/share/inkscape/extensions/pathmodifier.pyR.s
tPathModifiercBs�eZd�Zd�Zd�Zed�Zeed�Zd�Zd�Z	d�Z
ed�Zed	�Zed
�Z
ed�Zd�ZRS(
cCstjj|�dS(N(tinkextEffectt__init__(tself((s./usr/share/inkscape/extensions/pathmodifier.pyR;scCs�i}x~|j�D]p\}}tj|�}|jjd�d}|jd|j|��|j�j|�|||j	d�<qW|S(Nt}i����R(
t	iteritemstcopytdeepcopyttagtsplittsettuniqueIdt	getparentRR(RtaListtclonesRtnodetclonetmyid((s./usr/share/inkscape/extensions/pathmodifier.pytduplicateNodesBscCsnd|tjdd�f}xKt|jj�jd|dtj��rid|tjdd�f}qW|S(Ns%s%04iii's
//*[@id="%s"]t
namespaces(trandomtrandintRtdocumenttgetroottxpathRtNSS(RtprefixR((s./usr/share/inkscape/extensions/pathmodifier.pyRNs. c	Cs�x�|j�D]�\}}|jtjdd�ksC|jdkr
t|jd��}xJ|D]B}|r{t||�n|j|ji||jd�6��q_W|r�|jd�r�|j	d=n||=q
q
W|S(Ntgtsvgt	transformR(
titemsRRtaddNStparseTransformRtapplyTransformToNodetupdatetexpandGroupstattrib(RRttransferTransformRRtmatR
((s./usr/share/inkscape/extensions/pathmodifier.pyR/Ts*
*
c
Cs_xX|j�D]I}||}|jtjdd�ksH|jdkrn|j||�|j|||�q|jtjdd�ks�|jdkr|j|�}|j||�}||=tj	|j
d�p�d�}tj	|j
d�p�d�}	|j|	�|jdtj
|��|j
d�}
|j|ji||
6||��qqW|S(NR'R(tusetstyletR(tkeysRRR+R/texpandGroupsUnlinkClonestrefNodetunlinkClonetsimplestylet
parseStyleRR.RtformatStyle(RRR1t	doReplaceRRtrefnodetnewnodeR4trefstyletnewid((s./usr/share/inkscape/extensions/pathmodifier.pyR7as 
**
*cCsP|jd�r.|jd|j|j��nx|D]}|j|�q5WdS(NR(RRRRtrecursNewIds(RRR
((s./usr/share/inkscape/extensions/pathmodifier.pyRBws
cCsz|jtjdd��rm|jtjdd��}d|d}|jj�j|dtj�d}|Std�dS(Nthreftxlinks
//*[@id="%s"]iRis,Trying to follow empty xlink.href attribute.(RRR+R"R#R$R%tAssertionError(RRtrefidtpathtnewNode((s./usr/share/inkscape/extensions/pathmodifier.pyR8}s%cCs�|jtjdd�ks*|jdkr�tj|j|��}|j|�tt|j	d��|�|r�|j
�}|j|j|�|�|j
|�n|Std�dS(NR3R(R)sOnly clones can be unlinked...(RRR+RRR8RBR-R,RRtinserttindextremoveRE(RRR=RHtparent((s./usr/share/inkscape/extensions/pathmodifier.pyR9�s*
c

Cs�|jtjdd�kr�t|jd��}t|jd��}y.t|jd��}t|jd��}Wnd}d}nXt|jd��}t|jd	��}d
|||f}	|	d||||f7}	|	d||ddd
||||f7}	|	d|||||f7}	|	d||ddd
|||||f7}	|	d||||f7}	|	d||ddd
||||f7}	|	d|||f7}	|	d||ddd
|||f7}	tjjd�}
|
jd|	�|
jd|jd��|
jd|jd��|jd�}|ri|
jd|�t	|
�n|r�|j
�}|j|j|�|
�|j
|�n|
SdS(NtrectR(txtytrxtryitwidththeightsM %f,%f sL %f,%f sA %f,%f,%i,%i,%i,%f,%f iRGtdRR4R)(RRR+tfloatRtetreetElementRRt
fuseTransformRRIRJRK(
RRR=RNRORPRQtwthRTR?tnntRL((s./usr/share/inkscape/extensions/pathmodifier.pyt
rectToPath�sB
+ /+'
c
Cse|jtjdd�kr[tjj|jtjdd��}tj|jd�pWd�}g}xt|D]l}tj|jd�p�d�}|j	|�|j	|�|j
|t�}|tj
|jd��7}qjW|jdtj|��|jdtj|��|jj|�|rW|j�}	|	j|	j|�|�|	j|�n|St�dS(NR'R(RGR4R5RT(RRR+RVt
SubElementt
current_layerR:R;RR.tobjectToPathtFalsetcubicsuperpatht	parsePathRt
formatPathR<RKRRIRJRE(
RRR=RHtnewstyletnewpR
t
childstyletchildAsPathRL((s./usr/share/inkscape/extensions/pathmodifier.pytgroupToPath�s&$


 cCs;|jtjdd�kr+|j||�S|jtjdd�krV|j||�S|jtjdd�ks�|jdkr�x<|jj�D]+}d|ks�d|kr�|j|=q�q�Wt|�|S|jtjdd�ks�|jdkr|j||�}|j	||�Stj
td�|j�dSdS(	NRMR(R'RGtsodipoditinkscapeR3s3Please first convert objects to paths!  (Got [%s].)(
RRR+R\RhR0R6RXR9R_terrormsgt_tNone(RRR=tattNameRH((s./usr/share/inkscape/extensions/pathmodifier.pyR_�s*
*cCsSi}xF|j�D]8\}}|j||�}||=|||jd�<qWdS(NR(R*R_R(RRR=tnewSelectionRRR?((s./usr/share/inkscape/extensions/pathmodifier.pytobjectsToPaths�s
cCs�|j|jt�t|jj��|_xr|jj�D]a\}}|jtj	dd�kr;|j
d�}tj|�}|j
dtj|��q;q;WdS(NRGR(RT(RptselectedtTruetcomputeBBoxtvaluestbboxRRRR+RRaRbRRc(RRRRTtp((s./usr/share/inkscape/extensions/pathmodifier.pyteffect�s(t__name__t
__module__RRRRrR/R7RBR8R9R\RhR_RpRw(((s./usr/share/inkscape/extensions/pathmodifier.pyR:s			
				%
tDiffeocBs&eZd�Zdd�Zd�ZRS(cCstjj|�dS(N(RR
R(R((s./usr/share/inkscape/extensions/pathmodifier.pyRscCsvx6|D].}|dc|d8<|dc|d8<qWx6|D].}|dc|d7<|dc|d7<q@WdS(s}
        bpt is a base point and for v in vectors, v'=v-p is a tangent vector at bpt. 
        Defaults to identity!
        iiN((Rtbpttvectstv((s./usr/share/inkscape/extensions/pathmodifier.pytapplyDiffeos


c	Cs|j|jt�|j|jt�|j|jt�t|jj��|_x�|jj�D]�\}}|j	t
jdd�ks�|j	dkra|jd�}t
j|�}xA|D]9}x0|D](}|j|d|d|df�q�Wq�W|jdt
j|��qaqaWdS(NRGR(RTiii(R7RqRrR/RpRsRtRuRRRR+RRaRbR~RRc(RRRRTRvtsubtctlpt((s./usr/share/inkscape/extensions/pathmodifier.pyRw's*

*((RxRyRR~Rw(((s./usr/share/inkscape/extensions/pathmodifier.pyRz
s	(t__doc__RtmathtreR RRatbezmiscR:tsimpletransformRR
RRz(((s./usr/share/inkscape/extensions/pathmodifier.pyt<module>s
	�