mς
­fIc           @   s   d  Z  d d d d d d g Z d d Z d d	 Z d
 d Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d S(   sζ  Conversion functions between RGB and other color systems.

This modules provides two functions for each color system ABC:

  rgb_to_abc(r, g, b) --> a, b, c
  abc_to_rgb(a, b, c) --> r, g, b

All inputs and outputs are triples of floats in the range [0.0...1.0].
Inputs outside this range may cause exceptions or invalid outputs.

Supported color systems:
RGB: Red, Green, Blue components
YIQ: used by composite video signals
HLS: Hue, Luminance, Saturation
HSV: Hue, Saturation, Value
t
   rgb_to_yiqt
   yiq_to_rgbt
   rgb_to_hlst
   hls_to_rgbt
   rgb_to_hsvt
   hsv_to_rgbf1.0f3.0f6.0f2.0c         C   s[   d |  d | d | } d |  d | d | } d |  d | d	 | } | | | f S(
   Nf0.29999999999999999f0.58999999999999997f0.11f0.59999999999999998f0.28000000000000003f0.32000000000000001f0.20999999999999999f0.52000000000000002f0.31(   t   rt   gt   bt   yt   it   q(   R   R   R   R
   R   R	   (    (    t%   /mit/python/lib/python2.4/colorsys.pyR    "   s    c         C   sΩ   |  d | d | } |  d | d | } |  d | d | } | d j  o
 d } n | d j  o
 d } n | d j  o
 d } n | d j o
 d } n | d j o
 d } n | d j o
 d } n | | | f S(	   Nf0.94826200000000005f0.62401300000000004f0.27606599999999998f0.63980999999999999f1.10545f1.72986f0.0f1.0(   R	   R
   R   R   R   R   (   R	   R
   R   R   R   R   (    (    R   R   (   s      
 
 
 
 
 
c         C   s"  t  |  | |  }	 t |  | |  } | |	 d } | |	 j o d | d f Sn | d j o |	 | |	 | } n |	 | d |	 | } |	 |  |	 | } |	 | |	 | } |	 | |	 | } |  |	 j o | | }
 n. | |	 j o d | | }
 n d | | }
 |
 d d }
 |
 | | f S(   Nf2.0f0.0f0.5f4.0f6.0f1.0(   t   maxR   R   R   t   maxct   mint   minct   lt   st   rct   gct   bct   h(   R   R   R   R   R   R   R   R   R   R   R   (    (    R   R   :   s$        c         C   s   | d j o | | | f Sn | d j o | d | } n | | | | } d | | } t | | |  t  t | | |   t | | |  t  f S(   Nf0.0f0.5f1.0f2.0(   R   R   t   m2t   m1t   _vR   t	   ONE_THIRD(   R   R   R   R   R   (    (    R   R   K   s      c         C   sq   | d } | t j  o |  | |  | d Sn | d j  o | Sn | t j  o |  | |  t | d Sn |  S(   Nf1.0f6.0f0.5(   t   huet	   ONE_SIXTHR   R   t	   TWO_THIRD(   R   R   R   (    (    R   R   R   s    
   c         C   sο   t  |  | |  }	 t |  | |  } |	 } | |	 j o d d | f Sn |	 | |	 } |	 |  |	 | } |	 | |	 | } |	 | |	 | } |  |	 j o | | }
 n. | |	 j o d | | }
 n d | | }
 |
 d d }
 |
 | | f S(   Nf0.0f2.0f4.0f6.0f1.0(   R   R   R   R   R   R   R   t   vR   R   R   R   R   (   R   R   R   R   R   R   R   R   R   R   R   (    (    R   R   _   s        c         C   s.  | d j o | | | f Sn t |  d  } |  d | } | d | } | d | | } | d | d | } | d d j o | | | f Sn | d j o | | | f Sn | d j o | | | f Sn | d j o | | | f Sn | d	 j o | | | f Sn | d
 j o | | | f Sn d  S(   Nf0.0f6.0f1.0i   i    i   i   i   i   i   (	   R   R   t   intR   R
   t   ft   pR   t   t(   R   R   R   R    R
   R!   R   R"   (    (    R   R   n   s&           N(   t   __doc__t   __all__R   R   R   R    R   R   R   R   R   R   (   R   R   R$   R    R   R   R   R   R   R   R   (    (    R   t   ?   s   


						