Ë
    c­øc  ã                   óN   — d dl Z d dlZd dlmZ ddlmZ ddlmZ  G d„ de«      Zy)é    N)ÚGdké   )ÚAbstractBrush)Úutilities_smooth_pathc                   óL   ‡ — e Zd Zd Zd„ Zˆ fd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d„ Zˆ xZS )	ÚBrushSimplec                 óf   — t        d«      dz   }|r|t        d«      z  }|gS |t        d«      z  }|gS )NzSimple brushz - z$Width depends on the stylus pressurez Width depends on the mouse speed)Ú_)ÚselfÚuse_pressureÚbrush_directionÚlabels       ú6/usr/lib/python3/dist-packages/drawing/brush_simple.pyÚ	_get_tipszBrushSimple._get_tips   sF   € Ü
ˆNÓ
˜eÑ
#€%ÙØŒAÐ4Ó5Ñ5€5ð ˆ€.ð 	ŒAÐ0Ó1Ñ1€5Ø
ˆ€.ó    c                 óî   •— |j                  t        j                  j                  «       |j	                  t        j
                  j                  «        |j                  |d   Ž  t        ‰| �!  ||«       y )NÚrgba)	Úset_line_capÚcairoÚLineCapÚROUNDÚset_line_joinÚLineJoinÚset_source_rgbaÚsuperÚdraw_preview)r   Ú	operationÚcairo_contextÚ	__class__s      €r   r   zBrushSimple.draw_preview   sW   ø€ Ø×ÑœUŸ]™]×0Ñ0Ô1Ø×ÑœeŸn™n×2Ñ2Ô3Ø€-×Ñ ¨6Ñ!2Ñ3Ü�'Ñ�y -Õ0r   c                 ó¶   — |d   r0t        dt        |d   dz  «      «      |d<   | j                  ||«      S t        |d   «      dk  ry| j	                  ||«       y)zíBrush with dynamic width, where the variation of width is drawn by a
		succession of segments. If pressure is detected, the width is pressure-
		sensitive, otherwise it's speed-sensitive (with a heavy ponderation to
		make it less ugly).Ú
is_previewr   Ú
line_widthgš™™™™™é?Úpathé   N)ÚmaxÚintr   ÚlenÚoperation_on_mask)r   r   r   s      r   Údo_brush_operationzBrushSimple.do_brush_operation   sf   € ð ˆ|ÒÜ  ¤C¨	°,Ñ(?À#Ñ(EÓ$FÓG€9ˆ\ÑØ
×
Ñ
˜I }Ó
5Ð5äˆ�6Ñ	Ó˜aÒð 
à×Ñ˜ MÕ2r   c                 ó  — |j                  t        j                  j                  «       |j	                  t        j
                  j                  «       |j                  «        |d   D ]  }|j                  |d   |d   «       Œ |j                  «       }|d   r-|j                  «        t        ||«       |j                  «       }n|}| j                  |d   |d   «      }d}|j                  «        |D ]�  }|dz   }| j                  |«      \  }	}
}|	s|j                  |
|«       Œ2|j                  «       \  }}|j                  ||dz
     «       | j                  ||«       |j!                  «        |j                  |
|«       Œ‘ y )Nr#   ÚxÚyÚsmoothr"   r   r   )r   r   r   r   r   r   Únew_pathÚline_toÚ	copy_pathr   Ú_build_widthsÚ_future_pointÚmove_toÚget_current_pointÚset_line_widthÚ_add_segmentÚstroke)r   r   r   ÚptÚraw_pathÚsmoothed_pathÚwidthsÚiÚsegmentÚokÚfuture_xÚfuture_yÚ	current_xÚ	current_ys                 r   Údo_masked_brush_opzBrushSimple.do_masked_brush_op,   sx  € Ø×ÑœUŸ]™]×0Ñ0Ô1Ø×ÑœeŸn™n×2Ñ2Ô3ð ×ÑÔØ�fÑò +€bØ×Ñ˜˜C™ " S¡'Õ*ð+à×$Ñ$Ó&€(àˆxÒð ×ÑÔÜ˜¨Ô1Ø ×*Ñ*Ó,�=à€=ð ×Ñ˜i¨Ñ/°¸<Ñ1HÓI€&ð €!Ø×ÑÔØò 
-€gØˆ1�u€1Ø ×.Ñ.¨wÓ7Ñ€2€x�Ù
Ø×Ñ˜( HÔ-ØØ'×9Ñ9Ó;Ñ€9ˆiØ×Ñ  q¨1¡u¡Ô.Ø×Ñ�] GÔ,Ø×ÑÔØ×Ñ˜ 8Õ,ñ
-r   c           
      ó  — g }g }d}|D ]u  }|d   €2|�j|j                  | j                  |d   |d   |d   |d   «      «       n:|�8|d   dk(  s|d   dk(  rd}n|d   |d   z   dz  }|j                  ||z  dz  «       |}Œw t        |«      dk(  r|t        |«      }t	        |«      }	d}
|D ]_  }dt        |t	        dd|z  «      z  «      z   }|
dk(  r	||z   dz  }
n||
z   |
z   d	z  }
t	        dt        |
«      «      }|j                  |«       Œa |S )
z…Build an array of widths from the raw data, either using the value of
		the pressure or based on the estimated speed of the movement.NÚpr+   r,   r   é   r   gš™™™™™©?r$   )ÚappendÚ	_get_distr'   Úminr%   r&   )r   Úmanual_pathÚ
base_widthr;   ÚdistsÚp2r8   Ú	seg_widthÚmin_distÚmax_distÚ
temp_widthÚdistÚ	new_widthÚwidths                 r   r1   zBrushSimple._build_widthsT   sP  € ð €&Ø
€%Ø€"Øò €bØˆ�g€oà	€~Ø
‡\�\�$—.‘.  C¡¨"¨S©'°2°c±7¸B¸s¹GÓDÕEð 
€~Ø
ˆ3‰�1Š˜˜3™ 1šØ�ià�c‘7˜R ™WÑ$¨Ñ)€ið ‡]�]�: 	Ñ)¨AÑ-Ô.Ø
�2ðô$ 	ˆƒ[�AÒÜ�%‹j€8Ü�%‹j€8Ø€:Øò €tØ”C˜
¤S¨¨D°4©KÓ%8Ñ8Ó9Ñ9€IØ�Q‚Ø˜zÑ)¨QÑ.�Zà˜zÑ)¨JÑ6¸!Ñ;€ZÜ�”3�z“?Ó#€EØ
‡M�M�%Õðð 
€-r   c           	      ó8  — |d   t         j                  j                  k(  r;|j                  |d   d   |d   d   |d   d   |d   d   |d   d   |d   d   «       y |d   t         j                  j                  k(  r|j                  |d   d   |d   d   «       y y )Nr   r   rF   r$   é   é   )r   ÚPathDataTypeÚCURVE_TOÚcurve_toÚLINE_TOr/   )r   r   Úptss      r   r6   zBrushSimple._add_segment{   s£   € Øˆ�VŒu×!Ñ!×*Ñ*Ò*Ø×Ñ˜#˜a™& ™) S¨¡V¨A¡Y°°A±°q±	¸3¸q¹6À!¹9Ø03°A±°q±	¸3¸q¹6À!¹9õFà
ˆ1�v”×#Ñ#×+Ñ+Ò+Ø×Ñ˜˜Q™ ™ C¨¡F¨1¡IÕ.ð ,r   c                 óè   — |d   t         j                  j                  k(  rd|d   d   |d   d   fS |d   t         j                  j                  k(  rd|d   d   |d   d   fS d|d   d   |d   d   fS )Nr   Tr   rV   rW   F)r   rX   rY   r[   )r   r\   s     r   r2   zBrushSimple._future_point‚   s‰   € Øˆ�VŒu×!Ñ!×*Ñ*Ò*Ø
��A‘�q‘	˜3˜q™6 !™9Ð
$Ð$Ø
ˆ1�v”×#Ñ#×+Ñ+Ò+Ø
��A‘�q‘	˜3˜q™6 !™9Ð
$Ð$à
��Q‘˜‘˜C ™F 1™IÐ
%Ð%r   c                 óZ   — ||z
  ||z
  z  ||z
  ||z
  z  z   }t        j                  |«      S )N)ÚmathÚsqrt)r   Úx1Úy1Úx2Úy2Údist2s         r   rH   zBrushSimple._get_distŠ   s5   € Ø�‰7�r˜B‘wÑ
 2¨¡7¨r°B©wÑ"7Ñ
7€%Ü	�‰�5Ó	Ðr   )Ú__name__Ú
__module__Ú__qualname__Ú__gtype_name__r   r   r)   rC   r1   r6   r2   rH   Ú__classcell__)r   s   @r   r   r      s2   ø„ Ø€òô1ò3ò"#-òP%òN/ò&ör   r   )	r   r_   Úgi.repositoryr   Úabstract_brushr   Úutilities_pathsr   r   © r   r   ú<module>ro      s!   ð÷ Ý Ý )Ý 2ôD�-õ Dr   