\chapter{Module color}
\label{color}
\section{Color models}
PostScript provides different color models. They are available to
\PyX{} by different color classes, which just pass the colors down to
the PostScript level. This implies, that there are no conversion
routines between different color models available. However, some color
model conversion routines are included in Python's standard library in
the module \texttt{colorsym}. Furthermore also the comparision of
colors within a color model is not supported, but might be added in
future versions at least for checking color identity and for ordering
gray colors.

There is a class for each of the supported color models, namely
\verb|gray|, \verb|rgb|, \verb|cmyk|, and \verb|hsb|. The constructors
take variables appropriate to the color model. Additionally, a list of
named colors is given in appendix~\ref{colorname}.

\section{Example}
\begin{quote}
\begin{verbatim}
from pyx import *

c = canvas.canvas()

c.fill(path.rect(0, 0, 7, 3), [color.gray(0.8)])
c.fill(path.rect(1, 1, 1, 1), [color.rgb.red])
c.fill(path.rect(3, 1, 1, 1), [color.rgb.green])
c.fill(path.rect(5, 1, 1, 1), [color.rgb.blue])

c.writeEPSfile("color")
\end{verbatim}
\end{quote}

The file \verb|color.eps| is created and looks like:
\begin{quote}
\includegraphics{color}
\end{quote}

\section{Color palettes}

The color module provides a class \verb|palette|. The constructor of
that class receives two colors from the same color model and two
named parameters \verb|min| and \verb|max|, which are set to \verb|0|
and \verb|1| by default. Between those colors a linear interpolation
takes place by the method \verb|getcolor| depending on a value between
\verb|min| and \verb|max|.

A list of named palettes is available in appendix~\ref{palettename}.

