[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

6. Color

To support color, dvipng recognizes a certain set of specials as generated by the ‘color’ and ‘xcolor’ style files. These specials start with the keyword ‘color’ or the keyword ‘background’, followed by a color specification.


6.1 Color specifications

The color specification supported by dvipng is by-value or by-name. The by-value spec starts with the name of a color model (one of ‘rgb’, ‘hsb’, ‘cmy’, ‘cmyk’, or ‘gray’) followed by the appropriate number of parameters. Thus, the color specification ‘rgb 0.3 0.4 0.5’ would correspond to the color that is ‘0.3 0.4 0.5’ in its red, blue and green values. The color model used internally in dvipng is ‘RGB’ (discretized to 256 levels), for details on the formulas used in conversion, see the ‘xcolor’ documentation.

By-name color specifications are single (case-dependent) words and are compared with color names defined in ‘dvipsnam.def’ (from the ‘graphics’ bundle), ‘svgnam.def’ and ‘xcolor.sty’ (from the ‘xcolor’ bundle). See the ‘xcolor’ documentation for a list of names and the corresponding colors.

On the command-line, the name ‘Transparent’ can also be used as an argument to ‘--bg’ to choose transparent background. See section Option details.


6.2 Color specials

We will describe ‘background’ first, since it is the simplest. The ‘background’ keyword must be followed by a color specification. That color specification is used as a fill color for the background. The last ‘background’ special on a page is the one that gets used, and is used for the whole of the page image. (This is possible because the prescan phase of dvipng notices all of the color specials so that the appropriate information can be written out during the second phase.)

The ‘color’ special itself has three forms. The first is just ‘color’ followed by a color specification. In this case, the current global color is set to that color; the color stack must be empty when such a command is executed.

The second form is ‘color push’ followed by a color specification. This saves the current color on the color stack and sets the color to be that given by the color specification. This is the most common way to set a color.

The final form of the ‘color’ special is just ‘color pop’, with no color specification; this says to pop the color last pushed on the color stack from the color stack and set the current color to be that color.

dvipng correctly handles these color specials across pages, even when the pages are rendered repeatedly or in reverse order.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Jan-Åke on December 14, 2010 using texi2html 1.82.