12 PostScript provides different color models. They are available to PyX by
13 different color classes, which just pass the colors down to the PostScript
14 level. This implies, that there are no conversion routines between different
15 color models available. However, some color model conversion routines are
16 included in Python's standard library in the module ``colorsym``. Furthermore
17 also the comparison of colors within a color model is not supported, but might
18 be added in future versions at least for checking color identity and for
21 There is a class for each of the supported color models, namely ``gray``,
22 ``rgb``, ``cmyk``, and ``hsb``. The constructors take variables appropriate for
23 the color model. Additionally, a list of named colors is given in appendix
36 c.fill(path.rect(0, 0, 7, 3), [color.gray(0.8)])
37 c.fill(path.rect(1, 1, 1, 1), [color.rgb.red])
38 c.fill(path.rect(3, 1, 1, 1), [color.rgb.green])
39 c.fill(path.rect(5, 1, 1, 1), [color.rgb.blue])
41 c.writeEPSfile("color")
44 The file ``color.eps`` is created and looks like:
56 The color module provides a class :class:`gradient` for continous transitions between
57 colors. A list of named gradients is available in appendix :ref:`gradientname`.
60 .. class:: gradient(min=0, max=1)
62 This class provides the methods for the ``gradient``. Different initializations
63 can be found in ``lineargradient`` and ``functiongradient``.
65 *min* and *max* provide the valid range of the arguments for ``getcolor``.
68 .. function:: getcolor(parameter)
70 Returns the color that corresponds to *parameter* (must be between *min* and
74 .. function:: select(index, n_indices)
76 When a total number of *n_indices* different colors is needed from the gradient,
77 this method returns the *index*-th color.
80 .. class:: lineargradient(startcolor, endcolor, min=0, max=1)
82 This class provides a linear transition between two given colors. The linear
83 interpolation is performed on the color components of the specific color model.
85 *startcolor* and *endcolor* must be colors of the same color model.
88 .. class:: functiongradient(functions, type, min=0, max=1)
90 This class provides an arbitray transition between colors of the same color
93 *type* is a string indicating the color model (one of ``"cmyk"``, ``"rgb"``,
94 ``"hsb"``, ``"grey"``)
96 *functions* is a dictionary that maps the color components onto given functions.
97 E.g. for ``type="rgb"`` this dictionary must have the keys ``"r"``, ``"g"``, and
105 .. class:: transparency(value)
107 Instances of this class will make drawing operations (stroking, filling) to
108 become partially transparent. *value* defines the transparency factor in the
109 range ``0`` (opaque) to ``1`` (transparent).
111 Transparency is available in PDF output only since it is not supported by
112 PostScript. However, for certain ghostscript devices (for example the pdf
113 backend as used by ps2pdf) proprietary PostScript extension allows for
114 transparency in PostScript code too. PyX creates such PostScript proprietary
115 code, but issues a warning when doing so.