
    cc                      V    d dl Z 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   )AbstractClassicTool)utilities_smooth_pathc                        e Zd Zd Z fdZ fdZd Zd Zd Zd Z	d Z
ddZd	 Zd
 Zd Zd Zd Zd Zd Zd Z xZS )ToolExperimentc                 2   t         |   dt        d      d|       g | _        d| _        i dt
        j                  j                  dt
        j                  j                  dt
        j                  j                  dt
        j                  j                  d	t
        j                  j                  d
t
        j                  j                  dt
        j                  j                  dt
        j                  j                  dt
        j                  j                  dt
        j                  j                   dt
        j                  j"                  dt
        j                  j$                  dt
        j                  j&                  dt
        j                  j(                  dt
        j                  j*                  dt
        j                  j,                  dt
        j                  j.                  t
        j                  j0                  t
        j                  j2                  t
        j                  j4                  t
        j                  j6                  t
        j                  j8                  t
        j                  j:                  t
        j                  j<                  t
        j                  j>                  t
        j                  j@                  t
        j                  jB                  t
        j                  jD                  t
        j                  jF                  d| _$        d| _%        t
        j                  j                  | _&        d| _'        d| _(        | jS                  d| jJ                         | jS                  d| jN                         y )N
experiment
Experimentzapplications-utilities-symbolicTCLEARSOURCEOVERINOUTATOPDEST	DEST_OVERDEST_INDEST_OUT	DEST_ATOPXORADDSATURATEMULTIPLYSCREENOVERLAY)DARKENLIGHTENCOLOR_DODGE
COLOR_BURN
HARD_LIGHT
SOFT_LIGHT
DIFFERENCE	EXCLUSIONHSL_HUEHSL_SATURATION	HSL_COLORHSL_LUMINOSITYfeatherupexperiment_operatorexperiment_mode)*super__init____manual_path_use_antialiascairoOperatorr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   _operators_dict_operator_label	operator2_selected_mode_feather_diradd_tool_action_enum)selfwindowkwargs	__class__s      9/usr/lib/python3/dist-packages/drawing/tool_experiment.pyr.   zToolExperiment.__init__   s   '<<2SU[\
 $$
ENN  U^^"" 
5>> 			
 	%..

 
5>> 
5>> (( enn$$ u~~&& (( 	%..

 	%..

 u~~&& u~~&&  U^^""!" enn$$#$ ^^""nn$$..,,********((nn$$^^22((^^22;$>  $>>&&$.!$$143G3GH-t/B/BC    c                 v    t         |   |       | j                  j                         j	                  d       y )Nz	dim-label)r-   build_flowbox_child
_label_boxget_style_context	add_class)r:   flowboxr=   s     r>   rA   z"ToolExperiment.build_flowbox_child;   s+    'g&//##%//<r?   c                 F    | j                   dz   | j                         z   dgS )Nz - z8You're not supposed to use this tool (development only).)labelget_options_labelr:   s    r>   get_editing_tipszToolExperiment.get_editing_tips?   s)    ::..00=
 r?   c                     | j                          | j                          | j                  dk(  r| j                  S | j                  S )Nsimple)_set_active_operator_set_active_moder7   r5   rI   s    r>   rH   z ToolExperiment.get_options_labelE   s@    	H$





r?   c                 4    | j                  d      }|| _        y )Nr,   )get_option_valuer7   r:   argsstate_as_strings      r>   rN   zToolExperiment._set_active_modeO   s    ))*;</'$r?   c                 \    | j                  d      }| j                  |   | _        || _        y )Nr+   )rP   r4   r6   r5   rQ   s      r>   rM   z#ToolExperiment._set_active_operatorS   s-    ))*?@/''8$.($r?   c                     | j                          || _        || _        | j                  |j                  ||       g | _        | j                  |||       y N)rH   x_pressy_pressset_common_valuesbuttonr0   _add_pressured_point)r:   eventsurfaceevent_xevent_ys        r>   on_press_on_areazToolExperiment.on_press_on_areaZ   sL    $,$,w8$GWe4r?   c                 r    | j                  |||       |r"| j                         }| j                  |       y y rV   )r[   build_operationdo_tool_operation)r:   r\   r]   r^   r_   render	operations          r>   on_motion_on_areaz ToolExperiment.on_motion_on_areab   s8    GWe4##%9)$ r?   c                 v    | j                  |||       | j                         }d|d<   | j                  |       y )NF
is_preview)r[   rb   apply_operation)r:   r\   r]   r^   r_   re   s         r>   on_release_on_areaz!ToolExperiment.on_release_on_areah   s:    GWe4""$)!)Ly!r?   c                 d    ||| j                  |      d}| j                  j                  |       y )N)xyp)_get_pressurer0   append)r:   r^   r_   r\   	new_points        r>   r[   z#ToolExperiment._add_pressured_pointp   s3    5!)
 9%r?   c                     |j                         }|y |j                         }|j                         }|j                  t        j
                  j                        }|y |S rV   )get_source_device
get_sourceget_device_toolget_axisr   AxisUsePRESSURE)r:   r\   devicesourcetoolpressures         r>   ro   zToolExperiment._get_pressurex   s^    ""$&^
& 
			 $ ^^CKK001(
	/r?   c                    | j                   | j                  | j                  | j                  | j                  t
        j                  j                  t
        j                  j                  | j                  d| j                  d
}|S )NT)
tool_idrgbaoperatormode
line_widthline_cap	line_join	antialiasrh   path)id
main_colorr6   r7   
tool_widthr2   LineCapROUNDLineJoinr1   r0   )r:   re   s     r>   rb   zToolExperiment.build_operation   se    gg??~~}}""$$##) 
r?   c                    |d   t        |d         dk  ry | j                  |      }|j                  |d          |j                  |d           |j                  |d     |d   dk(  r>|d   r&t        |d	   d
z        |d	<   | j                  ||      S | j                  ||       y |d   dk(  r*|d   r| j                  ||      S | j                  ||       y |d   dk(  r| j                  ||       y | j                  ||       y )Nr   r   r   r   r   r   r|   rh   r      smoothzmacro-w)
lenstart_tool_operationset_line_capset_line_joinset_source_rgbaint	op_simpleop_pressure	op_smooth
op_macro_wr:   re   cairo_contexts      r>   rc   z ToolExperiment.do_tool_operation   s   v#i&7"81"<	++I6-Yz23i45-6!23v*$!)L"9A"=>Il>>)]33I}-H$>>)]33>>)]+I%??9m,>>)]+r?   c                 ,   |j                  t        j                  j                         |j	                  t        j
                  j                         |j                  |d          |j                          |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  dd	       |j                  d
d       |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                  dd       |j                          y)z7Trying to study whatever tf is the rendering issue #337r   2   F   Z   <   n   U      x         P         K         i  i"  i6  iJ  N)set_antialiasr2   	AntialiasDEFAULTset_operatorr3   r%   set_line_widthnew_pathline_tostroker   s      r>   r   zToolExperiment.op_macro_w   sM   eoo556U^^334y67BBBR S!S!R R R R S!R R R R r?   c                     |j                  |d          |j                  |d          |j                          |d   D ]  }|j                  |d   |d           |j	                          y )Nr   r   r   rl   rm   )r   r   r   r   r   )r:   re   r   pts       r>   r   zToolExperiment.op_simple   sl    Yz23y67f +bC"S'*+r?   c                 Z   |j                  t        j                  j                         |j	                  |d          |j                          |d   D ]  }|j                  |d   |d           |j                         }|j                          t        ||       |j                          y )Nr   r   rl   rm   )
r   r2   r3   r   r   r   r   	copy_pathr   r   )r:   re   r   r   r   s        r>   r   zToolExperiment.op_smooth   s    U^^001y67 f +bC"S'*+		 	 	"$ t, r?   )T)__name__
__module____qualname____gtype_name__r.   rA   rJ   rH   rN   rM   r`   rf   rj   r[   ro   rb   rc   r   r   r   __classcell__)r=   s   @r>   r   r      sZ    ".D`=()5%"&8,02r?   r   )
r2   mathrandomgi.repositoryr   abstract_classic_toolr   utilities_pathsr   r    r?   r>   <module>r      s%       6 2c( cr?   