Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/Tools/pynche/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/Tools/pynche/__pycache__/StripViewer.cpython-37.pyc

B

� fu<�@s�dZddlTddlZdZdZdZdZdZd	d
�Zdd�Z	d
d�Z
dd�Zdd�Zdd�Z
dd�ZGdd�d�ZGdd�de�ZGdd�d�ZGdd�d�ZdS)azStrip viewer and related widgets.

The classes in this file implement the StripViewer shown in the top two thirds
of the main Pynche window.  It consists of three StripWidgets which display
the variations in red, green, and blue respectively of the currently selected
r/g/b color value.

Each StripWidget shows the color variations that are reachable by varying an
axis of the currently selected color.  So for example, if the color is

  (R,G,B)=(127,163,196)

then the Red variations show colors from (0,163,196) to (255,163,196), the
Green variations show colors from (127,0,196) to (127,255,196), and the Blue
variations show colors from (127,163,0) to (127,163,255).

The selected color is always visible in all three StripWidgets, and in fact
each StripWidget highlights the selected color, and has an arrow pointing to
the selected chip, which includes the value along that particular axis.

Clicking on any chip in any StripWidget selects that color, and updates all
arrows and other windows.  By toggling on Update while dragging, Pynche will
select the color under the cursor while you drag it, but be forewarned that
this can be slow.
�)�*Nz�proc setcolor {canv colors} {
    set i 1
    foreach c $colors {
        $canv itemconfigure $i -fill $c -outline $c
        incr i
    }
}
���� cCsDd|d}d}g}x*|dkr>|�t|��||}|d}qW|S)Ng�o@�gr)�append�int)�numchips�step�start�seq�r�=/opt/alt/python37/lib64/python3.7/Tools/pynche/StripViewer.py�constant4s
rcCst|�}tt|g|||��S)N)r�list�zip)r
�red�green�bluer
rrr�constant_red_generator?srcCst|�}tt||g||��S)N)rrr)r
rrrr
rrr�constant_green_generatorDsrcCst|�}tt|||g|��S)N)rrr)r
rrrr
rrr�constant_blue_generatorIsrcCs$t|�}tt||g||g|��S)N)rrr)r
rrrr
rrr�constant_cyan_generatorNsrcCs$t|�}tt|g|||g|��S)N)rrr)r
rrrr
rrr�constant_magenta_generatorSsrcCs$t|�}tt|g||g||��S)N)rrr)r
rrrr
rrr�constant_yellow_generatorXsrc@sHeZdZdZdZdZdZdZdd�Zdd	�Z	d
d�Z
dd
�Zdd�ZdS)�	LeftArrow���
r)Z	leftarrowcCs&||_|�|�\|_|_|�|�dS)N)�_canvas�_createZ_LeftArrow__arrow�_LeftArrow__text�move_to)�self�canvas�xrrr�__init__eszLeftArrow.__init__cCsb|jj||j|j||j||j|jdd|jd�	}|jj||jd|j|j|jdd�}||fS)N�firstg@)�arrow�width�tagsr�128)r+�text)r �create_line�_ARROWHEIGHT�_YOFFSET�_ARROWWIDTH�_TAG�create_text�_TEXTYOFFSET)r$r&r)r-rrrr!js

zLeftArrow._createcCs"t|j�|j��}|st�|dS)Nr)rr �coordsr2�AssertionError)r$r5rrr�_xyszLeftArrow._xcCs"||��}|j�|j|d�dS)Nr)r7r Zmover2)r$r&Zdeltaxrrrr#~szLeftArrow.move_tocCs|jj|j|d�dS)N)r-)r �
itemconfigurer")r$r-rrr�set_text�szLeftArrow.set_textN)
�__name__�
__module__�__qualname__r1r/r0r4r2r'r!r7r#r9rrrrr^src@s eZdZdZdd�Zdd�ZdS)�
RightArrow)Z
rightarrowcCsj|jj||j||j|j||j|j|jdd|jd�	}|jj||jd|j|jtd|jd�}||fS)NZlastg@)r)r*r+rr,)Zjustifyr-r+)	r r.r0r1r/r2r3r4ZRIGHT)r$r&r)r-rrrr!�s


zRightArrow._createcCs(t|j�|j��}|st�|d|jS)Nr)rr r5r2r6r1)r$r5rrrr7�sz
RightArrow._xN)r:r;r<r2r!r7rrrrr=�sr=c	@s^eZdZdZdZdZdeeedddddf	dd�Zdd	�Zdd
d�Zdd
�Z	dd�Z
dd�ZdS)�StripWidget�2�
�(N�c
CsV||_||_||_|jdks t�|	|_|
|_d|_||_||d}|d}t|||d�}
|_	|
�
�|
�d|j�|
�d|j�|
�d|j�|
j
�t�g}|_d}d}d	}xLt|j�D]>}d
}|
j|||||||||d�||d}|�|�q�W|
jd||d
|td�|_|�d�}t|
|�|_|�t|�d�}t|
|�|_dS)N)rr�r�+)r*Zheightz<ButtonPress-1>z<ButtonRelease-1>z<B1-Motion>r)�chipZgrey)�fill�outliner+��)r-Zanchorr)�_StripWidget__generator�_StripWidget__axis�_StripWidget__numchipsr6�_StripWidget__uwd�_StripWidget__hexp�_StripWidget__lastchip�_StripWidget__sbZCanvas�_StripWidget__canvas�packZbind�_StripWidget__select_chip�tk�eval�TCLPROC�_StripWidget__chips�rangeZcreate_rectanglerr3�W�_StripWidget__label�_StripWidget__arrow_xr�_StripWidget__leftarrow�lenr=�_StripWidget__rightarrow)r$�switchboard�masterZ	chipwidthZ
chipheightr
�	generator�axis�label�uwdvar�hexvarZcanvaswidthZcanvasheightr%�chipsr&�yr+�c�colorZchipxrrrr'�sL


zStripWidget.__init__cCs0|j�|d�}|st�|\}}}}||dS)Nrg@)rQr5r6)r$Zchipnumr5Zx0Zy0Zx1Zy1rrrZ	__arrow_x�szStripWidget.__arrow_xcCs�|j}|j}|j}|�||||�}|r�d|dkr@|jkr�nnf|j|dd}t�|�\}}}	t|j	�}
|
t
ks�|j��r�|j
�|||	�n|�|d|||	f�dS)Nrr)r&rgrQZfind_overlappingrLrW�ColorDBZrrggbb_to_tripletr	�type�BTNUPrM�getrP�update_views�_StripWidget__trackarrow)r$�eventr&rgr%rErirrr�etyperrrZ
__select_chip�s"
zStripWidget.__select_chipcCs�|jdk	r,|j�|jd�}|jj|j|d�||_||j}|j��rPt|�}nt|�}|dkr�|j	�
|�|j	�|�|d��|j
�d�n.|j
�
|�|j
�|�|d��|j	�d�t�|�}|dkr�d}nd}|jj||d�dS)NrF)rG�ri����ZwhiteZblack)rOrQZitemcgetr8rKrNrm�hex�reprr\r9r#r[r^rjZtriplet_to_brightness)r$rEZrgbtupleriZ	coloraxisr-Z
brightnessrGrrrZ__trackarrows(




zStripWidget.__trackarrowcCs�|js
t�d}d}g}|_|jj}x\|�|j|||�D]F}t�|�}	|�|	�|\}
}}|
|krv||krv||krv|}|d}q8Wt	�
|�}
|�d|jj|
f�|�
||||f�dS)Nrrzsetcolor %s {%s})rJr6rWrQrTrLrjZtriplet_to_rrggbbr�SPACE�joinrUZ_wro)r$rrr�irErfrT�tZrrggbbZtredZtgreenZtblueZcolorsrrr�update_yourself#s





zStripWidget.update_yourselfcCs|jj|j|d�||_dS)N)r-)rQr8rZrJ)r$rcrarrr�set7szStripWidget.set)N)r:r;r<Z_CHIPHEIGHTZ
_CHIPWIDTHZ	_NUMCHIPSr'r[rSroryrzrrrrr>�s";
"r>c@sDeZdZddd�Zdd�Zddd�Zddd	�Zdd
d�Zdd
�ZdS)�StripViewerNc	Cs�||_|��}t|tdd�}|jddddd�t�}|_|�|�dd��t�}|_	|�|�dd��t|�}|j
ttd	�t
||tdd
||d�|_t
||tdd||d�|_t
||tdd
||d�|_t|�}|j
ttd	�|jddd�|jddd�d}	t|d|jd�}
|
jdddt|	d�t|d|d�}|jddtd�t|d||jd�}|jddtd�t|d|jd�}
|
jdddt|	d�dS)Nr)ZreliefZborderwidthrrCZNSEW)�row�columnZ
columnspan�sticky�UPWHILEDRAG�HEXSTRIP)�expandrFzRed Variations)rarbrcrdrezGreen VariationszBlue Variations�)ZweightrIZBlack)r-�command)r|r}Zrowspanr~�padxzUpdate while dragging)r-�variable)r|r}r~ZHexadecimal)r-r�r�ZWhite)�_StripViewer__sb�optiondbZFrameZRAISEDZgridZ
BooleanVar�_StripViewer__uwdvarrzrm�_StripViewer__hexpvarrRZYESZBOTHr>r�_StripViewer__redsr�_StripViewer__greensr�_StripViewer__bluesZcolumnconfigureZButton�_StripViewer__toblackrYZCheckbutton�_StripViewer__togglehex�_StripViewer__towhite�E)r$r_r`r��frameZuwdZhexpZframe1Zframe2r�ZblackbtnZuwdbtnZhexbtnZwhitebtnrrrr'=s^


zStripViewer.__init__cCs4|j�|||�|j�|||�|j�|||�dS)N)r�ryr�r�)r$rrrrrrry�szStripViewer.update_yourselfcCs"|j��\}}}|�|||�dS)N)r�Zcurrent_rgbry)r$rprrrrrrZ__togglehex�szStripViewer.__togglehexcCs|j�ddd�dS)Nr)r�rn)r$rprrrZ	__toblack�szStripViewer.__toblackcCs|j�ddd�dS)N�)r�rn)r$rprrrZ	__towhite�szStripViewer.__towhitecCs |j��|d<|j��|d<dS)Nrr�)r�rmr�)r$r�rrr�save_options�szStripViewer.save_options)N)N)N)N)	r:r;r<r'ryr�r�r�r�rrrrr{<s
O


r{)�__doc__ZtkinterrjrVZBTNDOWNrlZBTNDRAGrurrrrrrrrr=r>r{rrrr�<module>s&
(