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/pathalongpath.pyc
�
��Yc@s�dZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	d�Z
d�Zd�Zdd�Z
dejfd	��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����NcCs[xT|D]L}xC|D];}x2|D]*}|d}|d|d<||d<q!WqWqWdS(Nii((tpathtpathcomptctltptttmp((s//usr/share/inkscape/extensions/pathalongpath.pytflipxy.s



cCsFx?|D]7}x.|D]&}|dc|7<|dc|7<qWqWdS(Nii((RtdxtdyRR((s//usr/share/inkscape/extensions/pathalongpath.pytoffset6s

cCsjxc|D][}xR|D]J}|d|d|d||d<|d|d|d||d<qWqWdS(Nii((RtxscaletyscaletorgRR((s//usr/share/inkscape/extensions/pathalongpath.pytstretch<s

"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����(tlentbezmisct
pointdistancetbeziersplitatttinserttappendtrange(tpt	tolerancetzerotitdtlengthstboxtchordtb1tb2tnewtl((s//usr/share/inkscape/extensions/pathalongpath.pyt	linearizeBs*"*.&L(0b
D%t
PathAlongPathcBs8eZd�Zd�Zd�Zdd�Zd�ZRS(c
Cs�tjj|�|jjd�|jjdddddddd	d
ddd
�|jjddddddddd
ddd�|jjddddddddd
tdd�|jjddddddddd
tdd�|jjddddddddd
d�|jjdddddd dd!d
tdd"�|jjd#d$dddd dd%d
tdd&�|jjd'dddddd(dd)�dS(*Ns--titles-ns	--noffsettactiontstorettypetfloattdesttnoffsettdefaultgthelps
normal offsets-ts	--toffsetttoffsetstangential offsets-ks--kindtstringtkinds#choose between wave or snake effects-cs
--copymodetcopymodes(repeat the path to fit deformer's lengths-ps--spacetspaces-vs
--verticaltinkbooltverticalsreference path is verticals-ds--duplicatet	duplicates$duplicate pattern before deformations--tabttabs'The selected UI-tab when OK was pressed(tpathmodifiertDiffeot__init__tOptionParsert
add_optiontTruetFalse(tself((s//usr/share/inkscape/extensions/pathalongpath.pyR5bs>
cCs�|jj}tj|jj�|�}|d}i|j||6|_|jjrl|j	|j�|_n|j
|jtt�|j|j�|j|=|j|_
|j
|j
tt�|j|j
�dS(Ni����(toptionstidsR3tzSorttdocumenttgetroottselectedtpatternsR1tduplicateNodestexpandGroupsUnlinkClonesR8tobjectsToPathst	skeletonsR9(R:tidListtid((s//usr/share/inkscape/extensions/pathalongpath.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(tskelcompIsClosedtsumRR
tmin(R:RRtt((s//usr/share/inkscape/extensions/pathalongpath.pytlengthtotime�s	+'c
Cs�|d|jdd}|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|}	d}
|d|jdd}|jjr�||
||d<|||
|	|d<n4||
|||	|d<||
|	|||d<x�|D]�}|d|jdd|}
|d|jdd}|jjrh||
||d<|||
|	|d<q�||
|||	|d<||
|	|||d<q�WdS(s�
        The kernel of this stuff:
        bpt is a base point and for v in vectors, v'=v-p is a tangent vector at bpt.
        iii����N(tskelcompRMR
RttpointRR;twave(
R:tbpttvectstsRRLtxtyRRtvxtvytv((s//usr/share/inkscape/extensions/pathalongpath.pytapplyDiffeo�s01/2-//
cCst|jj�dkr/tjtd��dS|j�|jjdk|j_|jj	dkr~t
|j_t
|j_n�|jj	dkr�t
|j_t
|j_nZ|jj	dkr�t
|j_t
|j_n-|jj	dkrt
|j_t
|j_ntj|jj��}|jjrR|d|d|d	|d
f}n|d	|d
}||jj}|dkr�ttd��nxm|jj�D]\\}}|jtjd
d�ks�|jd
kr�|jd�}tj|�}|jjrt|�ng}x�|jj�D]�}	tj|	jd��|_|jjrct|j�nxy|jD]n}
tj |�}t!|
�\|_"|_#|j"d
|j"dk|_$t%|j#�}|j"d
d
|d
|jj&}
|j"d
d	|d|dd|jj'}|jjr�t(d	t)t*||jj|���}||}|j$ss||jj8}n|d
|d
||d|df}g}xQ|D]I}x@t+d
|d	�D],}|j,tj |��t-||d
�q�Wq�W|}nx|D]}t-||
|�qW|jjrt|sBttd��nx/|D]$}t|||d	|j"d
�qIWnxA|D]9}x0|D](}|j.|d	|d
|df�q�Wq{W|jjr�t|�n||7}qmWq&W|j/dtj0|��q�q�WdS(Nis+This extension requires two selected paths.tRibbontSingletRepeatedsSingle, stretchedsRepeated, stretchediiig{�G�z�?snThe total length of the pattern is too small :
Please choose a larger object or set 'Space between copies' > 0RtsvgRi����shThe 'stretch' option requires that the pattern must have non-zero width :
Please edit the pattern width.(1R
R;R<tinkexterrormsgt_RHR,RPR-R9trepeatRR8tsimpletransformtcomputeBBoxRAtvaluesR0R.texitt	iteritemsttagtaddNStgettcubicsuperpatht	parsePathRREt
itervaluestcurSekeletontcopytdeepcopyR RNRRIRJR*R'tmaxtinttroundRRRRYtsett
formatPath(R:tbboxtwidthRRGtnodeRtp0tnewptskelnodetcompRtlengthtxoffsettyoffsettNbCopiesRtsubRtctlpt((s//usr/share/inkscape/extensions/pathalongpath.pyteffect�s�
)*
#/)
	&
	

%

*
((t__name__t
__module__R5RHRMRYR�(((s//usr/share/inkscape/extensions/pathalongpath.pyR!as
	!		#t__main__(t__doc__RntmathtretrandomR^RjRR3RbRRRR R4R!R�tetaffect(((s//usr/share/inkscape/extensions/pathalongpath.pyt<module> s"			�