U
    g                     @   s\   d Z ddddddgZdZdZd	Zd
d Zdd Zdd Zdd Zdd Z	dd Z
dd ZdS )aJ  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]
(with the exception of I and Q, which covers a slightly larger range).
Inputs outside the valid range may cause exceptions or invalid outputs.

Supported color systems:
RGB: Red, Green, Blue components
YIQ: Luminance, Chrominance (used by composite video signals)
HLS: Hue, Luminance, Saturation
HSV: Hue, Saturation, Value

rgb_to_yiq
yiq_to_rgb
rgb_to_hls
hls_to_rgb
rgb_to_hsv
hsv_to_rgbgUUUUUU?gUUUUUU?gUUUUUU?c                 C   sR   d|  d|  d|  }d| |  d||   }d| |  d||   }|||fS )Ng333333?gzG?g)\(?gGz?gHzG?gQ?g=
ףp=? )rgbyiqr   r   /usr/lib/python3.8/colorsys.pyr   (   s    c                 C   s   | d|  d|  }| d|  d|  }| d|  d|  }|dk rHd}|dk rTd}|dk r`d}|dkrld}|dkrxd}|dkrd}|||fS )	Ng2rL?g,?g:?gnєW?g6޷?gJ"X?              ?r   )r   r   r   r   r	   r
   r   r   r   r   .   s     c                 C   s   t | ||}t| ||}|| d }||kr6d|dfS |dkrP|| ||  }n|| d| |  }||  ||  }|| ||  }|| ||  }	| |kr|	| }
n"||krd| |	 }
nd| | }
|
d d }
|
||fS )N       @r         ?      @      @r   maxmin)r   r	   r
   maxcminclsrcgcbchr   r   r   r   K   s$    

c                 C   sn   |dkr|||fS |dkr(|d|  }n|| ||  }d| | }t ||| t t ||| t ||| t fS )Nr   r   r   r   )_v	ONE_THIRD)r   r   r   m2m1r   r   r   r   b   s    
c                 C   sT   |d }|t k r$| ||  | d  S |dk r0|S |tk rP| ||  t|  d  S | S )Nr   r   r   )	ONE_SIXTH	TWO_THIRD)r#   r"   Zhuer   r   r   r    l   s    r    c                 C   s   t | ||}t| ||}|}||kr.dd|fS || | }||  ||  }|| ||  }|| ||  }	| |kr||	| }
n"||krd| |	 }
nd| | }
|
d d }
|
||fS )Nr   r   r   r   r   r   )r   r	   r
   r   r   vr   r   r   r   r   r   r   r   r   |   s     

c                 C   s   |dkr|||fS t | d }| d | }|d|  }|d||   }|d|d|    }|d }|dkrt|||fS |dkr|||fS |dkr|||fS |dkr|||fS |d	kr|||fS |d
kr|||fS d S )Nr   r   r                         )int)r   r   r&   r   fpr   tr   r   r   r      s(    





N)__doc____all__r!   r$   r%   r   r   r   r   r    r   r   r   r   r   r   <module>   s    	
