added mathtree bug
[PyX/mjg.git] / manual / color.tex
blobd9978bafc91987a37cbb8eec11340c325d48a80c
1 \chapter{Module color}
2 \label{color}
3 \section{Color models}
4 PostScript provides different color models. They are available to
5 \PyX{} by different color classes, which just pass the colors down to
6 the PostScript level. This implies, that there are no conversion
7 routines between different color models available. However, some color
8 model conversion routines are included in python's standard library in
9 the module \texttt{colorsym}. Furthermore also the comparision of
10 colors within a color model is not supported, but might be added in
11 future versions at least for checking color identity and for ordering
12 gray colors.
14 There is a class for each of the supported color models, namely
15 \verb|gray|, \verb|rgb|, \verb|cmyk|, and \verb|hsb|. The constructors
16 take variables appropriate to the color model. Additionally, a list of
17 named colors is given in appendix~\ref{colorname}.
19 \section{Example}
20 \begin{quote}
21 \begin{verbatim}
22 from pyx import *
24 c = canvas.canvas()
26 c.fill(path.rect(0, 0, 7, 3), color.gray(0.8))
27 c.fill(path.rect(1, 1, 1, 1), color.rgb.red)
28 c.fill(path.rect(3, 1, 1, 1), color.rgb.green)
29 c.fill(path.rect(5, 1, 1, 1), color.rgb.blue)
31 c.writetofile("color")
32 \end{verbatim}
33 \end{quote}
35 The file \verb|color.eps| is created and looks like:
36 \begin{quote}
37 \includegraphics{color}
38 \end{quote}
40 \section{Color palettes}
42 The color module provides a class \verb|palette|. The constructor of
43 that class receives two colors from the same color model and two
44 named parameters \verb|min| and \verb|max|, which are set to \verb|0|
45 and \verb|1| by default. Between those colors a linear interpolation
46 takes place by the method \verb|getcolor| depending on a value between
47 \verb|min| and \verb|max|.
49 A list of named palettes is available in appendix~\ref{palettename}.