???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................ó
¿œ^c           @   sÌ   d  Z  d d l Td d l Z d Z d Z d Z d Z d Z d	 „  Z d
 „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d d d „  ƒ  YZ d e f d „  ƒ  YZ d d d „  ƒ  YZ d d d „  ƒ  YZ d S(   sz  Strip 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.
iÿÿÿÿ(   t   *Ns   proc setcolor {canv colors} {
    set i 1
    foreach c $colors {
        $canv itemconfigure $i -fill $c -outline $c
        incr i
    }
}
i   i   i   t    c         C   sX   d |  d } d } g  } x7 |  d k rS | j  t | ƒ ƒ | | } |  d }  q W| S(   Ng     ào@i   g        i    (   t   appendt   int(   t   numchipst   stept   startt   seq(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant4   s    
c         C   s&   t  |  ƒ } t d  | g |  | | ƒ S(   N(   R   t   mapt   None(   R   t   redt   greent   blueR   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant_red_generator?   s    c         C   s&   t  |  ƒ } t d  | | g |  | ƒ S(   N(   R   R	   R
   (   R   R   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant_green_generatorD   s    c         C   s&   t  |  ƒ } t d  | | | g |  ƒ S(   N(   R   R	   R
   (   R   R   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant_blue_generatorI   s    c         C   s-   t  |  ƒ } t d  | | g |  | g |  ƒ S(   N(   R   R	   R
   (   R   R   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant_cyan_generatorN   s    c         C   s-   t  |  ƒ } t d  | g |  | | g |  ƒ S(   N(   R   R	   R
   (   R   R   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant_magenta_generatorS   s    c         C   s-   t  |  ƒ } t d  | g |  | g |  | ƒ S(   N(   R   R	   R
   (   R   R   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   constant_yellow_generatorX   s    t	   LeftArrowc           B   sS   e  Z d  Z d Z d Z d Z d
 Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(   i   i   i   i   t	   leftarrowc         C   s5   | |  _  |  j | ƒ \ |  _ |  _ |  j | ƒ d  S(   N(   t   _canvast   _createt   _LeftArrow__arrowt   _LeftArrow__textt   move_to(   t   selft   canvast   x(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   __init__e   s    	c         C   s   |  j  j | |  j |  j | |  j | |  j |  j d d d d d |  j ƒ} |  j  j | |  j d |  j |  j d |  j d d ƒ} | | f S(	   Nt   arrowt   firstt   widthg      @t   tagsi   t   textt   128(   R   t   create_linet   _ARROWHEIGHTt   _YOFFSETt   _ARROWWIDTHt   _TAGt   create_textt   _TEXTYOFFSET(   R   R   R   R#   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   j   s    					c         C   s   |  j  j |  j ƒ } | d S(   Ni    (   R   t   coordsR)   (   R   R,   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   _xy   s    c         C   s-   | |  j  ƒ  } |  j j |  j | d ƒ d  S(   Ni    (   R-   R   t   moveR)   (   R   R   t   deltax(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   ~   s    c         C   s   |  j  j |  j d | ƒd  S(   NR#   (   R   t   itemconfigureR   (   R   R#   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   set_text‚   s    (   R   (   t   __name__t
   __module__R(   R&   R'   R+   R)   R   R   R-   R   R1   (    (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   ^   s   				t
   RightArrowc           B   s    e  Z d Z d „  Z d „  Z RS(   t
   rightarrowc         C   s   |  j  j | |  j | |  j |  j | |  j |  j |  j d d d d d |  j ƒ} |  j  j | |  j d |  j |  j d t d d	 d |  j ƒ} | | f S(
   NR   t   lastR!   g      @R"   i   t   justifyR#   R$   (	   R   R%   R'   R(   R&   R)   R*   R+   t   RIGHT(   R   R   R   R#   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   ‰   s    			c         C   s$   |  j  j |  j ƒ } | d |  j S(   Ni    (   R   R,   R)   R(   (   R   R,   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR-   ™   s    (   R5   (   R2   R3   R)   R   R-   (    (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR4   †   s   	t   StripWidgetc        
   B   sn   e  Z d  Z d Z d Z d
 e e e d
 d
 d d
 d
 d „	 Z d „  Z d
 d „ Z d „  Z	 d „  Z
 d	 „  Z RS(   i2   i
   i(   t    c         C   sÌ  | |  _  | |  _ | |  _ |	 |  _ |
 |  _ d  |  _ | |  _ | | d } | d } t | d | d | ƒ} |  _	 | j
 ƒ  | j d |  j ƒ | j d |  j ƒ | j d |  j ƒ | j j t ƒ g  } |  _ d } d } d } xh t |  j ƒ D]W } d
 } | j | | | | | | d | d | d | ƒ| | d } | j | ƒ qø W| j d | | d d | d t ƒ|  _ |  j d ƒ } t | | ƒ |  _ |  j t | ƒ d ƒ } t | | ƒ |  _ d  S(   Ni   i+   R!   t   heights   <ButtonPress-1>s   <ButtonRelease-1>s   <B1-Motion>i   t   chipt   greyt   fillt   outlineR"   i   i   R#   t   anchori    (   R<   (   t   _StripWidget__generatort   _StripWidget__axist   _StripWidget__numchipst   _StripWidget__uwdt   _StripWidget__hexpR
   t   _StripWidget__lastchipt   _StripWidget__sbt   Canvast   _StripWidget__canvast   packt   bindt   _StripWidget__select_chipt   tkt   evalt   TCLPROCt   _StripWidget__chipst   ranget   create_rectangleR   R*   t   Wt   _StripWidget__labelt   _StripWidget__arrow_xR   t   _StripWidget__leftarrowt   lenR4   t   _StripWidget__rightarrow(   R   t   switchboardt   mastert	   chipwidtht
   chipheightR   t	   generatort   axist   labelt   uwdvart   hexvart   canvaswidtht   canvasheightR   t   chipsR   t   yR"   t   ct   colort   chipx(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   ¥   sJ    							
	
c         C   s4   |  j  j | d ƒ } | \ } } } } | | d S(   Ni   g       @(   RI   R,   (   R   t   chipnumR,   t   x0t   y0t   x1t   y1(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt	   __arrow_xé   s    c         C   sð   | j  } | j } |  j } | j | | | | ƒ } | rì d | d k oW |  j k n rì |  j | d d } t j | ƒ \ } } }	 t | j	 ƒ }
 |
 t
 k s³ |  j j ƒ  rÌ |  j j | | |	 ƒ qì |  j | d | | |	 f ƒ n  d  S(   Ni   i    (   R   Re   RI   t   find_overlappingRC   RP   t   ColorDBt   rrggbb_to_tripletR   t   typet   BTNUPRD   t   getRG   t   update_viewst   _StripWidget__trackarrow(   R   t   eventR   Re   R   R<   Rg   R   R   R   t   etype(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   __select_chipñ   s    			)c         C   sP  |  j  d  k	 rC |  j j |  j  d ƒ } |  j j |  j  d | ƒn  | |  _  | |  j } |  j j ƒ  rw t | ƒ } n t	 | ƒ } | d k rÏ |  j
 j | ƒ |  j
 j |  j | d ƒ ƒ |  j j d ƒ n= |  j j | ƒ |  j j |  j | d ƒ ƒ |  j
 j d ƒ t j | ƒ } | d k r0d } n d } |  j j | d | ƒd  S(   NR>   R?   i€   i   iœÿÿÿt   whitet   black(   RF   R
   RI   t   itemcgetR0   RB   RE   Rt   t   hext   reprRV   R1   R   RU   RX   Rp   t   triplet_to_brightness(   R   R<   t   rgbtupleRg   t	   coloraxisR#   t
   brightnessR?   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   __trackarrow  s(    		c         C   sö   d } d } g  } |  _  |  j j } x… |  j |  j | | | ƒ D]h } t j | ƒ }	 | j |	 ƒ | \ }
 } } |
 | k rŸ | | k rŸ | | k rŸ | } n  | d } qA Wt j	 | ƒ } | j
 d |  j j | f ƒ |  j | | | | f ƒ d  S(   Ni   i    s   setcolor %s {%s}(   RP   RI   RM   RA   RC   Rp   t   triplet_to_rrggbbR   t   SPACEt   joinRN   t   _wRv   (   R   R   R   R   t   iR<   Rd   RM   t   tt   rrggbbt   tredt   tgreent   tbluet   colors(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   update_yourself#  s    "$	c         C   s&   |  j  j |  j d | ƒ| |  _ d  S(   NR#   (   RI   R0   RT   RA   (   R   R_   R]   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   set7  s    N(   R2   R3   t   _CHIPHEIGHTt
   _CHIPWIDTHt	   _NUMCHIPSR
   R   RU   RL   Rv   R   R   (    (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR9       s"   ;		"	t   StripViewerc           B   sJ   e  Z d d  „ Z d „  Z d d „ Z d d „ Z d d „ Z d „  Z RS(   c         C   sœ  | |  _  | j ƒ  } t | d t d d ƒ} | j d d d d d d d	 d
 ƒ t ƒ  } |  _ | j | j d d ƒ ƒ t ƒ  } |  _	 | j | j d d ƒ ƒ t | ƒ } | j
 d t d t ƒ t | | d t d d d d d | d | ƒ|  _ t | | d t d d d d d | d | ƒ|  _ t | | d t d d d d d | d | ƒ|  _ t | ƒ } | j
 d t d t ƒ | j d d d ƒ| j d d d ƒd }	 t | d d d |  j ƒ}
 |
 j d d d d d d d	 t d |	 ƒ t | d d d  | ƒ} | j d d d d d	 t ƒ t | d d! d  | d |  j ƒ} | j d d d d d	 t ƒ t | d d" d |  j ƒ} | j d d d d d d d	 t d |	 ƒ d  S(#   Nt   relieft   borderwidthi   t   rowt   columni    t
   columnspani   t   stickyt   NSEWt   UPWHILEDRAGt   HEXSTRIPt   expandR>   R]   R^   R_   s   Red VariationsR`   Ra   s   Green Variationss   Blue Variationst   weighti   i   R#   t   Blackt   commandt   rowspant   padxs   Update while draggingt   variablet   Hexadecimalt   White(   t   _StripViewer__sbt   optiondbt   Framet   RAISEDt   gridt
   BooleanVart   _StripViewer__uwdvarR   Rt   t   _StripViewer__hexpvarRJ   t   YESt   BOTHR9   R   t   _StripViewer__redsR   t   _StripViewer__greensR   t   _StripViewer__bluest   columnconfiguret   Buttont   _StripViewer__toblackRS   t   Checkbuttont   _StripViewer__togglehext   _StripViewer__towhitet   E(   R   RY   RZ   R¨   t   framet   uwdt   hexpt   frame1t   frame2R£   t   blackbtnt   uwdbtnt   hexbtnt   whitebtn(    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   =  s^    	"	(				c         C   sF   |  j  j | | | ƒ |  j j | | | ƒ |  j j | | | ƒ d  S(   N(   R±   R   R²   R³   (   R   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR   Œ  s    c         C   s/   |  j  j ƒ  \ } } } |  j | | | ƒ d  S(   N(   R§   t   current_rgbR   (   R   Rw   R   R   R   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   __togglehex‘  s    c         C   s   |  j  j d d d ƒ d  S(   Ni    (   R§   Ru   (   R   Rw   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt	   __toblack©  s    c         C   s   |  j  j d d d ƒ d  S(   Niÿ   (   R§   Ru   (   R   Rw   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt	   __towhite¬  s    c         C   s*   |  j  j ƒ  | d <|  j j ƒ  | d <d  S(   NRœ   R   (   R­   Rt   R®   (   R   R¨   (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   save_options¯  s    N(	   R2   R3   R
   R   R   R¸   R¶   R¹   RÈ   (    (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyR”   <  s   O	(    (    (    (   t   __doc__t   TkinterRp   RO   t   BTNDOWNRs   t   BTNDRAGR…   R   R   R   R   R   R   R   R   R4   R9   R”   (    (    (    s8   /usr/lib64/python2.7/site-packages/pynche/StripViewer.pyt   <module>   s$   
							(œ