manpagez: man pages & more
info groff
Home | html | info | man

File: groff.info,  Node: Colors,  Next: Strings,  Prev: Manipulating Type Size and Vertical Spacing,  Up: GNU troff Reference

5.21 Colors
===========

GNU 'troff' supports color output with a variety of color spaces and up
to 16 bits per channel.  Some devices, particularly terminals, may be
more limited.  When color support is enabled, two colors are current at
any given time: the "stroke color", with which glyphs, rules (lines),
and geometric objects like circles and polygons are drawn, and the "fill
color", which can be used to paint the interior of a closed geometric
figure.

 -- Request: .color [n]
 -- Register: \n[.color]
     If N is missing or non-zero, enable the output of color-related
     device-independent output commands (this is the default);
     otherwise, disable them.  This request sets a global flag; it does
     not produce an input token (*note Gtroff Internals::).

     The read-only register '.color' is 1 if colors are enabled,
     0 otherwise.

     Color can also be disabled with the '-c' command-line option.

 -- Request: .defcolor ident scheme color-component ...
     Define a color named IDENT.  SCHEME selects a color space and
     determines the quantity of required COLOR-COMPONENTs; it must be
     one of 'rgb' (three components), 'cmy' (three), 'cmyk' (four), or
     'gray' (one).  'grey' is accepted as a synonym of 'gray'.  The
     color components can be encoded as a single hexadecimal value
     starting with '#' or '##'.  The former indicates that each
     component is in the range 0-255 (0-FF), the latter the range
     0-65,535 (0-FFFF).

          .defcolor half gray #7f
          .defcolor pink rgb #FFC0CB
          .defcolor magenta rgb  ##ffff0000ffff

     Alternatively, each color component can be specified as a decimal
     fraction in the range 0-1, interpreted using a default scaling unit
     of 'f', which multiplies its value by 65,536 (but clamps it at
     65,535).

          .defcolor gray50 rgb 0.5 0.5 0.5
          .defcolor darkgreen rgb 0.1f 0.5f 0.2f

   Each output device has a color named 'default', which cannot be
redefined.  A device's default stroke and fill colors are not
necessarily the same.  For the 'dvi', 'html', 'pdf', 'ps', and 'xhtml'
output devices, GNU 'troff' automatically loads a macro file defining
many color names at startup.  By the same mechanism, the devices
supported by 'grotty' recognize the eight standard ISO 6429/EMCA-48
color names.(1)  (*note Colors-Footnote-1::)

 -- Request: .gcolor [color]
 -- Escape sequence: \mc
 -- Escape sequence: \m(co
 -- Escape sequence: \m[color]
 -- Register: \n[.m]
     Set the stroke color to COLOR.

          .gcolor red
          The next words
          .gcolor
          \m[red]are in red\m[]
          and these words are in the previous color.

     The escape sequence '\m[]' restores the previous stroke color, as
     does a 'gcolor' request without an argument.

     The name of the current stroke color is available in the read-only
     string-valued register '.m'; it is associated with the environment
     (*note Environments::).  It interpolates nothing when the stroke
     color is the default.

     '\m' doesn't produce an input token in GNU 'troff' (*note Gtroff
     Internals::).  It therefore can be used in requests like 'mc'
     (which expects a single character as an argument) to change the
     color on the fly:

          .mc \m[red]x\m[]

 -- Request: .fcolor [color]
 -- Escape sequence: \Mc
 -- Escape sequence: \M(co
 -- Escape sequence: \M[color]
 -- Register: \n[.M]
     Set the fill color for objects drawn with '\D'...'' escape
     sequences.  The escape sequence '\M[]' restores the previous fill
     color, as does an 'fcolor' request without an argument.

     The name of the current fill color is available in the read-only
     string-valued register '.M'; it is associated with the environment
     (*note Environments::).  It interpolates nothing when the fill
     color is the default.  '\M' doesn't produce an input token in GNU
     'troff'.

     Create an ellipse with a red interior as follows.

          \M[red]\h'0.5i'\D'E 2i 1i'\M[]

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.