blob: 274837733ca5bfedda14c3cdbf8d756ae859c1ec [file] [log] [blame]
Fred Drake32c562b1999-04-19 21:20:13 +00001\section{\module{colorsys} ---
2 Conversions between color systems}
3
4\declaremodule{standard}{colorsys}
5\modulesynopsis{Conversion functions between RGB and other color systems.}
6\sectionauthor{David Ascher}{da@python.net}
7
8The \module{colorsys} module defines bidirectional conversions of
9color values between colors expressed in the RGB (Red Green Blue)
10color space used in computer monitors and three other coordinate
11systems: YIQ, HLS (Hue Lightness Saturation) and HSV (Hue Saturation
12Value). Coordinates in all of these color spaces are floating point
13values. In the YIQ space, the Y coordinate is between 0 and 1, but
14the I and Q coordinates can be positive or negative. In all other
15spaces, the coordinates are all between 0 and 1.
16
17More information about color spaces can be found at
Brett Cannon35415da2003-12-11 04:37:24 +000018\url{http://www.poynton.com/ColorFAQ.html}.
Fred Drake32c562b1999-04-19 21:20:13 +000019
20The \module{colorsys} module defines the following functions:
21
22\begin{funcdesc}{rgb_to_yiq}{r, g, b}
23Convert the color from RGB coordinates to YIQ coordinates.
24\end{funcdesc}
25
26\begin{funcdesc}{yiq_to_rgb}{y, i, q}
27Convert the color from YIQ coordinates to RGB coordinates.
28\end{funcdesc}
29
30\begin{funcdesc}{rgb_to_hls}{r, g, b}
31Convert the color from RGB coordinates to HLS coordinates.
32\end{funcdesc}
33
34\begin{funcdesc}{hls_to_rgb}{h, l, s}
35Convert the color from HLS coordinates to RGB coordinates.
36\end{funcdesc}
37
38\begin{funcdesc}{rgb_to_hsv}{r, g, b}
39Convert the color from RGB coordinates to HSV coordinates.
40\end{funcdesc}
41
42\begin{funcdesc}{hsv_to_rgb}{h, s, v}
43Convert the color from HSV coordinates to RGB coordinates.
44\end{funcdesc}
45
46Example:
47
48\begin{verbatim}
49>>> import colorsys
50>>> colorsys.rgb_to_hsv(.3, .4, .2)
51(0.25, 0.5, 0.4)
52>>> colorsys.hsv_to_rgb(0.25, 0.5, 0.4)
53(0.3, 0.4, 0.2)
54\end{verbatim}