<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--Converted with LaTeX2HTML 98.2 beta6 (August 14th, 1998)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>14.4 colorsys --
Conversions between color systems</TITLE>
<META NAME="description" CONTENT="14.4 colorsys --
Conversions between color systems">
<META NAME="keywords" CONTENT="lib">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<LINK REL="STYLESHEET" HREF="lib.css">
<LINK REL="next" HREF="module-rgbimg.html">
<LINK REL="previous" HREF="module-aifc.html">
<LINK REL="up" HREF="mmedia.html">
<LINK REL="next" HREF="module-rgbimg.html">
</HEAD>
<BODY bgcolor="#ffffff">
<div class=navigation>
<table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-rgbimg.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="mmedia.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-aifc.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-rgbimg.html">14.5 rgbimg  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="mmedia.html">14. Multimedia Services</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-aifc.html">14.3 aifc  </A></span>
<br><hr></div>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0016400000000000000000">
14.4 <tt class=module>colorsys</tt> --
         Conversions between color systems</A>
</H1>

<P>


<P>
The <tt class=module>colorsys</tt> module defines bidirectional conversions of
color values between colors expressed in the RGB (Red Green Blue)
color space used in computer monitors and three other coordinate
systems: YIQ, HLS (Hue Lightness Saturation) and HSV (Hue Saturation
Value).  Coordinates in all of these color spaces are floating point
values.  In the YIQ space, the Y coordinate is between 0 and 1, but
the I and Q coordinates can be positive or negative.  In all other
spaces, the coordinates are all between 0 and 1.

<P>
More information about color spaces can be found at 
<span class=url><a href="http://www.inforamp.net/%7epoynton/ColorFAQ.html">http://www.inforamp.net/%7epoynton/ColorFAQ.html</a></span>.

<P>
The <tt class=module>colorsys</tt> module defines the following functions:

<P>
<dl><dt><b><a name="l2h-2271"><tt class=function>rgb_to_yiq</tt></a></b> (<var>r, g, b</var>)
<dd>
Convert the color from RGB coordinates to YIQ coordinates.
</dl>

<P>
<dl><dt><b><a name="l2h-2272"><tt class=function>yiq_to_rgb</tt></a></b> (<var>y, i, q</var>)
<dd>
Convert the color from YIQ coordinates to RGB coordinates.
</dl>

<P>
<dl><dt><b><a name="l2h-2273"><tt class=function>rgb_to_hls</tt></a></b> (<var>r, g, b</var>)
<dd>
Convert the color from RGB coordinates to HLS coordinates.
</dl>

<P>
<dl><dt><b><a name="l2h-2274"><tt class=function>hls_to_rgb</tt></a></b> (<var>h, l, s</var>)
<dd>
Convert the color from HLS coordinates to RGB coordinates.
</dl>

<P>
<dl><dt><b><a name="l2h-2275"><tt class=function>rgb_to_hsv</tt></a></b> (<var>r, g, b</var>)
<dd>
Convert the color from RGB coordinates to HSV coordinates.
</dl>

<P>
<dl><dt><b><a name="l2h-2276"><tt class=function>hsv_to_rgb</tt></a></b> (<var>h, s, v</var>)
<dd>
Convert the color from HSV coordinates to RGB coordinates.
</dl>

<P>
Example:

<P>
<dl><dd><pre class=verbatim>
&gt;&gt;&gt; import colorsys
&gt;&gt;&gt; colorsys.rgb_to_hsv(.3, .4, .2)
(0.25, 0.5, 0.4)
&gt;&gt;&gt; colorsys.hsv_to_rgb(0.25, 0.5, 0.4)
(0.3, 0.4, 0.2)
</pre></dl><p>
<div class=navigation><hr><table align=center width="100%" cellpadding=0 cellspacing=2>
<tr>
<td><A HREF="module-rgbimg.html"><img width=32 height=32 align=bottom border=0 alt="next"
 src="../icons/next.gif"></A></td>
<td><A HREF="mmedia.html"><img width=32 height=32 align=bottom border=0 alt="up"
 src="../icons/up.gif"></A></td>
<td><A HREF="module-aifc.html"><img width=32 height=32 align=bottom border=0 alt="previous"
 src="../icons/previous.gif"></A></td>
<td align=center bgcolor="#99CCFF" width="100%">
 <b class=title>Python Library Reference</b></td>
<td><A HREF="contents.html"><img width=32 height=32 align=bottom border=0 alt="contents"
 src="../icons/contents.gif"></A></td>
<td><a
 href="modindex.html"><img width=32 height=32 align=bottom border=0 alt="modules"
 src="../icons/modules.gif"></a></td>
<td><A HREF="genindex.html"><img width=32 height=32 align=bottom border=0 alt="index"
 src="../icons/index.gif"></A></td>
</tr></table><b class=navlabel>Next:</b> <span class=sectref><A HREF="module-rgbimg.html">14.5 rgbimg  </A></span>
<b class=navlabel>Up:</b> <span class=sectref><A HREF="mmedia.html">14. Multimedia Services</A></span>
<b class=navlabel>Previous:</b> <span class=sectref><A HREF="module-aifc.html">14.3 aifc  </A></span>
</div>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>Send comments on this document to <a href="mailto:python-docs@python.org">python-docs@python.org</a>.
</ADDRESS>
</BODY>
</HTML>
