| 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 : |
o
0�a�H � @ s� d Z ddlmZ ddlmZ ddlZddlZddlmZmZmZm Z m
Z
mZ dZG dd� de
�Zdd
d�Zddd
�ZG dd� dej�ZedkrNe� �� dS dS )a�
TODO: mark elements that have previously been snapped, along with the settings
used, so that the same settings can be used for that element next time when
it's selected as part of a group (and add an option to the extension dialog
"Use previous/default settings" which is selected by default)
TODO: make elem_offset return [x_offset, y_offset] so we can handle non-symetric scaling
=> will probably need to take into account non-symetric scaling on stroke-widths,
too (horizontal vs vertical strokes)
TODO: Transforming points isn't quite perfect, to say the least. In particular,
when translating a point on a bezier curve, we translate the handles by the same amount.
BUT, some handles that are attached to a particular point are conceptually
handles of the prev/next node.
Best way to fix it would be to keep a list of the fractional_offsets[] of
each point, without transforming anything. Then go through each point and
transform the appropriate handle according to the relevant fraction_offset
in the list.
i.e. calculate first, then modify.
In fact, that might be a simpler algorithm anyway -- it avoids having
to keep track of all the first_xy/next_xy guff.
Note: This doesn't work very well on paths which have both straight segments
and curved segments.
The biggest three problems are:
a) we don't take handles into account (segments where the nodes are
aligned are always treated as straight segments, even where the
handles make it curve)
b) when we snap a straight segment right before/after a curve, it
doesn't make any attempt to keep the transition from the straight
segment to the curve smooth.
c) no attempt is made to keep equal widths equal. (or nearly-equal
widths nearly-equal). For example, font strokes.
Note: Paths that have curves & arcs on some sides of the bounding box won't
be snapped correctly on that side of the bounding box, and nor will they
be translated/resized correctly before the path is modified. Doesn't affect
most applications of this extension, but it highlights the fact that we
take a geometrically simplistic approach to inspecting & modifying the path.
� )�division)�print_functionN)�PathElement�Group�Image� Rectangle�ShapeElement� Transform� c @ s e Zd ZdS )�TransformErrorN)�__name__�
__module__�__qualname__� r r �+/usr/share/inkscape/extensions/pixelsnap.pyr L s r Fc C s |r| } | � |�S )z#apply_to_point with inbuilt inverse)�apply_to_point)� transform�pt�inverser r r �transform_pointO s
r c C sb |r| } |dur|| j 9 }|dur|| j9 }|dur#|dur#||fS |dur)|S |dur/|S dS )z� Dimensions don't get translated. I'm not sure how much diff rotate/skew
makes in this context, but we currently ignore anything besides scale.
N)�a�d)r �width�heightr r r r �transform_dimensionsU s
�r c @ s� e Zd Zdd� Zdd� Zdd� Zd"dd �Zd"d
d�Zdd
� Zd"dd�Z d"dd�Z
d"dd�Zdd� Zd"dd�Z
d"dd�Zd"dd�Zd"dd�Zd"dd�Zd d!� ZdS )#� PixelSnapc C sD |j ddtjddd� |j ddtjddd� |j d d
tddd� d
S )zAdd inx optionsz-az--snap_ancestorsTzOSnap unselected ancestors' translations (groups, layers, document height) first)�type�default�helpz-tz--ancestor_offsetz_Calculate offset relative to unselected ancestors' transforms (includes document height offset)z-gz--max_gradientg �?z&Maximum slope to consider straight (%)N)�add_argument�inkex�Boolean�float)�self�parsr r r �
add_argumentsj s ��
�zPixelSnap.add_argumentsc C s\ t |d |d �}t |d |d �}|dkr|dkrdS |dkr$dS || | jjd k S �Nr � TF�d )�abs�options�max_gradient�r# �pt1�pt2�hlen�vlenr r r �verticalu s zPixelSnap.verticalc C sh t t|d |d �t�}t t|d |d �t�}|dkr$|dkr$dS |dkr*dS || | jjd k S r&