📄 module-colorsys.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>14.7 colorsys -- Conversions between color systems</title>
<META NAME="description" CONTENT="14.7 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" tppabs="http://www.python.org/doc/current/lib/lib.css">
<LINK REL="next" href="module-rgbimg.html" tppabs="http://www.python.org/doc/current/lib/module-rgbimg.html">
<LINK REL="previous" href="module-chunk.html" tppabs="http://www.python.org/doc/current/lib/module-chunk.html">
<LINK REL="up" href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html">
<LINK REL="next" href="module-rgbimg.html" tppabs="http://www.python.org/doc/current/lib/module-rgbimg.html">
</head>
<body>
<DIV CLASS="navigation"><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-chunk.html" tppabs="http://www.python.org/doc/current/lib/module-chunk.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-rgbimg.html" tppabs="http://www.python.org/doc/current/lib/module-rgbimg.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-chunk.html" tppabs="http://www.python.org/doc/current/lib/module-chunk.html">14.6 chunk </A>
<b class="navlabel">Up:</b> <a class="sectref" href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html">14. Multimedia Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-rgbimg.html" tppabs="http://www.python.org/doc/current/lib/module-rgbimg.html">14.8 rgbimg </A>
<br><hr></DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION0016700000000000000000">
14.7 <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
<a class="url" href="javascript:if(confirm('http://www.inforamp.net/%7epoynton/ColorFAQ.html \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address. \n\nDo you want to open it from the server?'))window.location='http://www.inforamp.net/%7epoynton/ColorFAQ.html'" tppabs="http://www.inforamp.net/%7epoynton/ColorFAQ.html">http://www.inforamp.net/%7epoynton/ColorFAQ.html <img src="offsite.gif" tppabs="http://www.python.org/doc/current/icons/offsite.gif"
border='0' class='offsitelink' height='15' width='17' alt='[off-site link]'
></a>.
<P>
The <tt class="module">colorsys</tt> module defines the following functions:
<P>
<dl><dt><b><a name='l2h-2920'><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-2921'><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-2922'><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-2923'><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-2924'><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-2925'><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">
>>> import colorsys
>>> colorsys.rgb_to_hsv(.3, .4, .2)
(0.25, 0.5, 0.4)
>>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4)
(0.3, 0.4, 0.2)
</pre></dl>
<DIV CLASS="navigation"><p><hr><table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="module-chunk.html" tppabs="http://www.python.org/doc/current/lib/module-chunk.html"><img src="previous.gif" tppabs="http://www.python.org/doc/current/icons/previous.gif" border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html"><img src="up.gif" tppabs="http://www.python.org/doc/current/icons/up.gif" border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="module-rgbimg.html" tppabs="http://www.python.org/doc/current/lib/module-rgbimg.html"><img src="next.gif" tppabs="http://www.python.org/doc/current/icons/next.gif" border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td><A href="contents.html" tppabs="http://www.python.org/doc/current/lib/contents.html"><img src="contents.gif" tppabs="http://www.python.org/doc/current/icons/contents.gif" border="0" height="32"
alt="Contents" width="32"></A></td>
<td><a href="modindex.html" tppabs="http://www.python.org/doc/current/lib/modindex.html" title="Module Index"><img src="modules.gif" tppabs="http://www.python.org/doc/current/icons/modules.gif" border="0" height="32"
alt="Module Index" width="32"></a></td>
<td><A href="genindex.html" tppabs="http://www.python.org/doc/current/lib/genindex.html"><img src="index.gif" tppabs="http://www.python.org/doc/current/icons/index.gif" border="0" height="32"
alt="Index" width="32"></A></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="module-chunk.html" tppabs="http://www.python.org/doc/current/lib/module-chunk.html">14.6 chunk </A>
<b class="navlabel">Up:</b> <a class="sectref" href="mmedia.html" tppabs="http://www.python.org/doc/current/lib/mmedia.html">14. Multimedia Services</A>
<b class="navlabel">Next:</b> <a class="sectref" href="module-rgbimg.html" tppabs="http://www.python.org/doc/current/lib/module-rgbimg.html">14.8 rgbimg </A>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
<hr>See <i><a href="about.html" tppabs="http://www.python.org/doc/current/lib/about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -