Your IP : 216.73.216.213


Current Path : /opt/alt/python34/lib64/python3.4/Tools/pynche/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/Tools/pynche/__pycache__/StripViewer.cpython-34.pyc

�
e 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
    }
}
���� cCsXd|d}d}g}x7|dkrS|jt|��||}|d}qW|S)Ng�o@�gr)�append�int)�numchips�step�start�seq�r�=/opt/alt/python34/lib64/python3.4/Tools/pynche/StripViewer.py�constant4s
rcCs)t|�}tt|g|||��S)N)r�list�zip)r
�red�green�bluer
rrr�constant_red_generator?srcCs)t|�}tt||g||��S)N)rrr)r
rrrr
rrr�constant_green_generatorDsrcCs)t|�}tt|||g|��S)N)rrr)r
rrrr
rrr�constant_blue_generatorIsrcCs0t|�}tt||g||g|��S)N)rrr)r
rrrr
rrr�constant_cyan_generatorNsrcCs0t|�}tt|g|||g|��S)N)rrr)r
rrrr
rrr�constant_magenta_generatorSsrcCs0t|�}tt|g||g||��S)N)rrr)r
rrrr
rrr�constant_yellow_generatorXsrc@sjeZdZdZdZdZdZdZdd�Zdd	�Z	d
d�Z
dd
�Zdd�ZdS)�	LeftArrow���
r�	leftarrowcCs5||_|j|�\|_|_|j|�dS)N)�_canvas�_createZ_LeftArrow__arrow�_LeftArrow__text�move_to)�self�canvas�xrrr�__init__es	zLeftArrow.__init__c
Cs�|jj||j|j||j||j|jddddd|j�}|jj||jd|j|jd|jdd�}||fS)	N�arrow�first�widthg@�tagsr�text�128)r!�create_line�_ARROWHEIGHT�_YOFFSET�_ARROWWIDTH�_TAG�create_text�_TEXTYOFFSET)r%r'r)r-rrrr"js					zLeftArrow._createcCs/t|jj|j��}|s't�|dS)Nr)rr!�coordsr3�AssertionError)r%r6rrr�_xyszLeftArrow._xcCs-||j�}|jj|j|d�dS)Nr)r8r!Zmover3)r%r'Zdeltaxrrrr$~szLeftArrow.move_tocCs|jj|jd|�dS)Nr-)r!�
itemconfigurer#)r%r-rrr�set_text�szLeftArrow.set_textN)r )
�__name__�
__module__�__qualname__r2r0r1r5r3r(r"r8r$r:rrrrr^src@s.eZdZdZdd�Zdd�ZdS)�
RightArrow�
rightarrowc
Cs�|jj||j||j|j||j|j|jddddd|j�}|jj||jd|j|jdtdd	d|j�}||fS)
Nr)�lastr+g@r,rZjustifyr-r.)	r!r/r1r2r0r3r4r5ZRIGHT)r%r'r)r-rrrr"�s			zRightArrow._createcCs6t|jj|j��}|s't�|d|jS)Nr)rr!r6r3r7r2)r%r6rrrr8�sz
RightArrow._xN)r?)r;r<r=r3r"r8rrrrr>�sr>c@s�eZdZdZdZdZdeeeddddddd�	Zdd	�Zdd
d�Zdd
�Z	dd�Z
dd�ZdS)�StripWidget�2�
�(N�cCs�||_||_||_|jdks0t�|	|_|
|_d|_||_||d}|d}t|d|d|�}
|_	|
j
�|
jd|j�|
jd|j�|
jd	|j�|
j
jt�g}|_d}d
}d}xht|j�D]W}d}|
j||||||d
|d|d|�||d}|j|�q
W|
jd||dd|dt�|_|jd�}t|
|�|_|jt|�d�}t|
|�|_dS)Nrr��+r+Zheightz<ButtonPress-1>z<ButtonRelease-1>z<B1-Motion>r�chipZgrey�fill�outliner,��r-Zanchor)rrrF)zchip)�_StripWidget__generator�_StripWidget__axis�_StripWidget__numchipsr7�_StripWidget__uwd�_StripWidget__hexp�_StripWidget__lastchip�_StripWidget__sbZCanvas�_StripWidget__canvas�packZbind�_StripWidget__select_chip�tk�eval�TCLPROC�_StripWidget__chips�rangeZcreate_rectanglerr4�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__cCs@|jj|d�}|s"t�|\}}}}||dS)Nrg@)rTr6r7)r%Zchipnumr6Zx0Zy0Zx1Zy1rrrZ	__arrow_x�szStripWidget.__arrow_xcCs�|j}|j}|j}|j||||�}|r�d|dkoW|jknr�|j|dd}tj|�\}}}	t|j	�}
|
t
ks�|jj�r�|j
j|||	�q�|j|d|||	f�ndS)Nrr)r'rjrTZfind_overlappingrOrZ�ColorDBZrrggbb_to_tripletr	�type�BTNUPrP�getrS�update_views�_StripWidget__trackarrow)r%�eventr'rjr&rHrlrrr�etyperrrZ
__select_chip�s			)zStripWidget.__select_chipcCsP|jdk	rC|jj|jd�}|jj|jd|�n||_||j}|jj�rwt|�}nt|�}|dkr�|j	j
|�|j	j|j|d��|j
jd�n=|j
j
|�|j
j|j|d��|j	jd	�tj|�}|dkr0d}nd}|jj|d|�dS)
NrIrJ�r�dZwhiteZblacki����i����)rRrTZitemcgetr9rNrQrp�hex�reprr_r:r$r^rarmZtriplet_to_brightness)r%rHZrgbtuplerlZ	coloraxisr-Z
brightnessrJrrrZ__trackarrows(	
	zStripWidget.__trackarrowcCs|jst�d}d}g}|_|jj}x�|j|j|||�D]h}tj|�}	|j|	�|\}
}}|
|kr�||kr�||kr�|}n|d}qPWt	j
|�}
|jd|jj|
f�|j
||||f�dS)Nrrzsetcolor %s {%s})rMr7rZrTrWrOrmZtriplet_to_rrggbbr�SPACE�joinrXZ_wrr)r%rrr�irHrirW�tZrrggbbZtredZtgreenZtblueZcolorsrrr�update_yourself#s
"
$	zStripWidget.update_yourselfcCs&|jj|jd|�||_dS)Nr-)rTr9r]rM)r%rfrdrrr�set7szStripWidget.set)r;r<r=Z_CHIPHEIGHTZ
_CHIPWIDTHZ	_NUMCHIPSr(r^rVrrr}r~rrrrrA�s";"rAc@sdeZdZddd�Zdd�Zddd�Zddd	�Zdd
d�Zdd
�ZdS)�StripViewerNc
Cs�||_|j�}t|dtdd�}|jddddddd	d
�t�}|_|j|jdd��t�}|_	|j|jdd��t|�}|j
d
tdt�t
||dtddddd|d|�|_t
||dtddddd|d|�|_t
||dtddddd|d|�|_t|�}|j
d
tdt�|jddd�|jddd�d}	t|ddd|j�}
|
jddddddd	td|	�t|ddd |�}|jddddd	t�t|dd!d |d|j�}|jddddd	t�t|dd"d|j�}
|
jddddddd	td|	�dS)#NZreliefZborderwidthr�row�columnrZ
columnspanrFZstickyZNSEW�UPWHILEDRAG�HEXSTRIP�expandrIrdrerfzRed VariationsrgrhzGreen VariationszBlue VariationsZweight�rLr-ZBlackZcommandZrowspan�padxzUpdate while draggingZvariableZHexadecimalZWhite)�_StripViewer__sb�optiondbZFrameZRAISEDZgridZ
BooleanVar�_StripViewer__uwdvarr~rp�_StripViewer__hexpvarrUZYESZBOTHrAr�_StripViewer__redsr�_StripViewer__greensr�_StripViewer__bluesZcolumnconfigureZButton�_StripViewer__toblackr\ZCheckbutton�_StripViewer__togglehex�_StripViewer__towhite�E)r%rbrcr�ZframeZuwdZhexpZframe1Zframe2r�ZblackbtnZuwdbtnZhexbtnZwhitebtnrrrr(=s^	"	(				zStripViewer.__init__cCsF|jj|||�|jj|||�|jj|||�dS)N)r�r}r�r�)r%rrrrrrr}�szStripViewer.update_yourselfcCs/|jj�\}}}|j|||�dS)N)r�Zcurrent_rgbr})r%rsrrrrrrZ__togglehex�szStripViewer.__togglehexcCs|jjddd�dS)Nr)r�rq)r%rsrrrZ	__toblack�szStripViewer.__toblackcCs|jjddd�dS)N�)r�rq)r%rsrrrZ	__towhite�szStripViewer.__towhitecCs*|jj�|d<|jj�|d<dS)Nr�r�)r�rpr�)r%r�rrr�save_options�szStripViewer.save_options)	r;r<r=r(r}r�r�r�r�rrrrr<sOr)�__doc__ZtkinterrmrYZBTNDOWNroZBTNDRAGryrrrrrrrrr>rArrrrr�<module>s$

(�