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/pathscatter.pyc
�
��Yc@s�dZddlZddlZddlZddlZddlmZddlZddlZddl	Z	ddl
Z
ddlZd�Zd�Z
d�Zd�Zdd	�Zd
e
jfd��YZedkr�e�Zej�ndS(
sa
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

Quick description:
This script deforms an object (the pattern) along other paths (skeletons)...
The first selected object is the pattern
the last selected ones are the skeletons.

Imagine a straight horizontal line L in the middle of the bounding box of the pattern.
Consider the normal bundle of L: the collection of all the vertical lines meeting L.
Consider this as the initial state of the plane; in particular, think of the pattern
as painted on these lines.

Now move and bend L to make it fit a skeleton, and see what happens to the normals:
they move and rotate, deforming the pattern.
i����N(tetreecCsug}|jd�}||kr1|j|�nx=|D]5}t|�t|�krZPn|t||�7}q8W|S(Ntid(tgettappendtlentzSort(tinNodetidListt
sortedListttheidtchild((s-/usr/share/inkscape/extensions/pathscatter.pyR/s
cCs[xT|D]L}xC|D];}x2|D]*}|d}|d|d<||d<q!WqWqWdS(Nii((tpathtpathcomptctltptttmp((s-/usr/share/inkscape/extensions/pathscatter.pytflipxy;s



cCsFx?|D]7}x.|D]&}|dc|7<|dc|7<qWqWdS(Nii((RtdxtdyR
R((s-/usr/share/inkscape/extensions/pathscatter.pytoffsetCs

cCsjxc|D][}xR|D]J}|d|d|d||d<|d|d|d||d<qWqWdS(Nii((RtxscaletyscaletorgR
R((s-/usr/share/inkscape/extensions/pathscatter.pytstretchIs

"g����MbP?cCs�d}d}d}g}x�|t|�dkrtj||d||d�}|tj||d||dd�7}|tj||dd||dd�7}tj||d||dd�}|||kr�tj||d||d||dd||ddgd�\}}	|d\||dd<||dd<|	d\||ddd<||ddd<|j|d|dd|ddg|dd|ddg|	dd|	ddgg�q||d}|j|�|d7}qWgtdt|�d�D]$}|||kr*||d^q*}
|
j|dd�g|D]}||krp|^qp}|
|fS(sr
    This function receives a component of a 'cubicsuperpath' and returns two things:
    The path subdivided in many straight segments, and an array containing the length of each segment.
    
    We could work with bezier path as well, but bezier arc lengths are (re)computed for each point 
    in the deformed object. For complex paths, this might take a while.
    g���ư>iiig�?ii����(Rtbezmisct
pointdistancetbeziersplitatttinsertRtrange(tpt	tolerancetzerotitdtlengthstboxtchordtb1tb2tnewtl((s-/usr/share/inkscape/extensions/pathscatter.pyt	linearizeOs*"*.&L(0b
D%tPathScattercBs8eZd�Zd�Zd�Zed�Zd�ZRS(c
Cs0tjj|�|jjd�|jjdddddddd	d
ddd
�|jjddddddddd
ddd�|jjddddddddd
tdd�|jjddddddddd
ddd�|jjddddddddd
tdd �|jjd!d"dddddd#d
tdd$�|jjd%d&dddddd'd
d�|jjd(d)dddddd*d
tdd+�|jjd,d-dddddd.d
tdd/�|jjd0d1dddddd2d
d3dd/�|jjd4dddddd5dd6�dS(7Ns--titles-ns	--noffsettactiontstorettypetfloattdesttnoffsettdefaultgthelps
normal offsets-ts	--toffsetttoffsetstangential offsets-gs--grouppicktinkboolt	grouppicks6if pattern is a group then randomly pick group memberss-ms
--pickmodetstringtpickmodetrands.group pick mode (rand=random seq=sequentially)s-fs--followtfollows#choose between wave or snake effects-ss	--stretchRs(repeat the path to fit deformer's lengths-ps--spacetspaces-vs
--verticaltverticalsreference path is verticals-ds--duplicatet	duplicates$duplicate pattern before deformations-cs
--copymodetcopymodetclones--tabttabs'The selected UI-tab when OK was pressed(tpathmodifiertDiffeot__init__tOptionParsert
add_optiontFalsetTrue(tself((s-/usr/share/inkscape/extensions/pathscatter.pyRBosV
cCsB|jj}t|jj�|�}|d}|j||_tjd�|_	|jj
�j|j	�|jjdkr�|j
i|j|6�}|j�d|_nd|jjdkr�tjd�|_|jjdd	|�|j	j|j�n|j|_|j|=|j|jtt�|j|jt�dS(
Ni����s{http://www.w3.org/2000/svg}gtcopyis%sR>s{http://www.w3.org/2000/svg}uses"{http://www.w3.org/1999/xlink}hrefs#%s(toptionstidsRtdocumenttgetroottselectedtpatternNodeRtElementtgNodet	getparentRR=tduplicateNodestvaluestsett	skeletonstexpandGroupsUnlinkClonesRFREtobjectsToPaths(RGRRtduplist((s-/usr/share/inkscape/extensions/pathscatter.pytprepareSelectionList�s"

cCs�|jr|t|j�}n|dkr@d||jdfSd}xG|t|j�kr�|j||kr�||j|8}|d7}qIW||jt|t|j�d�}||fS(s
        Recieves an arc length l, and returns the index of the segment in self.skelcomp 
        containing the corresponding point, to gether with the position of the point on this segment.

        If the deformer is closed, do computations modulo the toal length.
        ii(tskelcompIsClosedtsumR"Rtmin(RGR(R tt((s-/usr/share/inkscape/extensions/pathscatter.pytlengthtotime�s	+'c
Cs�|j|�\}}|t|j�dkr�tj|j|d|j|d|�\}}|j|d|j|dd|jd}|j|d|j|dd|jd}n�tj|j||j|d|�\}}|j|dd|j|d|j|}|j|dd|j|d|j|}|rs|||g|||gg}	ndd|gdd|gg}	|	S(s�
        receives a length, and returns the coresponding point and tangent of self.skelcomp
        if follow is set to false, returns only the translation
        iii����(R^RtskelcompRttpointR"(
RGtsR9R R]txtyRRtmat((s-/usr/share/inkscape/extensions/pathscatter.pytlocalTransformAt�s1/2-//"c
Csgt|jj�dkr/tjtd��dS|j�tj|j	g�}dd|d|ddgdd|d|ddgg}|jj
r�|d|d|d|dg}tjdddgdddgg|�}n|ddc|jj
7<tj||j	�|d|d}||jj}g}|jjr�|j	jtjdd�ks||j	jdkr�tj|j	jd	��}xA|j	D]#}tj||�|j|�q�Wn|j|j	�d}xf|jj�D]U}tj|jd
��|_x1|jD]&}	t|	�\|_|_|jd|jdk|_t|j�}
|jj r�||jj}t!|
|jj"|jj|�}|dkr�|
|jj"|}q�n|jdd|d|jj"}|jdd|d|dd|jj
}
|jj"}x||
krA|j#||jj$�}|jj%dkr�t&j'|t(j)dt|�d��}n|jj%dkr�t&j'||�}|dt|�}n|t(j)dt|�d�jj*d
�d}|j+d|j,|��|j-j|�tj||�||7}q-WqWq�W|j	j.�j/|j	�dS(Nis+This extension requires two selected paths.iiii����tgtsvgt	transformR!R8tseqt}R(0RRIRJtinkexterrormsgt_RYR@tcomputeBBoxRNR;tsimpletransformtcomposeTransformR0tapplyTransformToNodeR:R5ttagtaddNStparseTransformRRRUt
itervaluestcubicsuperpatht	parsePathtcurSekeletonR)R_R"RZR[RtintR3ReR9R7RHtdeepcopytrandomtrandinttsplitRTtuniqueIdRPRQtremove(RGtbboxRdtwidthRtpatternListR
tcountertskelnodetcomptlengthtntxoffsettyoffsetRaR>tmyid((s-/usr/share/inkscape/extensions/pathscatter.pyteffect�s`
@$-<$#/,0(t__name__t
__module__RBRYR^RFReR�(((s-/usr/share/inkscape/extensions/pathscatter.pyR*ns
	-		t__main__(t__doc__RHtmathtreR{tlxmlRRkRvRR@RoRRRRR)RAR*R�tetaffect(((s-/usr/share/inkscape/extensions/pathscatter.pyt<module> s&				�