cairodriver.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <!-- meta page description: Cairo DISPLAY DRIVER -->
  2. <em>Cairo display driver</em> for bitmap or vector output using the
  3. Cairo graphics library.
  4. <h2>DESCRIPTION</h2>
  5. The Cairo driver generates PNG, BMP, PPM, PS, PDF or SVG images by
  6. GRASS display commands, using the
  7. <a href="http://www.cairographics.org/">Cairo graphics library</a>.
  8. The image format is selected from the extension of the output file.
  9. The Cairo driver is used for GRASS display commands by default if
  10. available, otherwise <em><a href="pngdriver.html">PNG driver</a></em>
  11. is used.
  12. <h2>USAGE</h2>
  13. <h3>Environment variables</h3>
  14. The Cairo driver can be enabled by
  15. setting <b>GRASS_RENDER_IMMEDIATE</b> variable, eg.
  16. <div class="code"><pre>
  17. export GRASS_RENDER_IMMEDIATE=cairo
  18. </pre></div>
  19. Several environment variables affect the operation of the Cairo driver:
  20. <ul>
  21. <li><b>GRASS_RENDER_WIDTH=xxx</b><br>
  22. the width of the image map (default is 640).
  23. </li>
  24. <li><b>GRASS_RENDER_HEIGHT=yyy</b><br>
  25. the height of the image map (default is 480).
  26. </li>
  27. <li><b>GRASS_RENDER_BACKGROUNDCOLOR=RRGGBB</b><br>
  28. specifies the background color to use in RGB notation (hex or
  29. R:G:B values). Named colors are also supported. Default
  30. is <b>FFFFFF</b> (white).
  31. </li>
  32. <li><b>GRASS_RENDER_TRANSPARENT=[TRUE|FALSE]</b><br>
  33. sets transparent background on (TRUE) or off (FALSE, default).
  34. </li>
  35. <li><b>GRASS_RENDER_ANTIALIAS</b><br> can be <em>default</em>,
  36. <em>none</em>, <em>gray</em>, or <em>subpixel</em>, corresponding to
  37. <a href="http://www.cairographics.org/manual/cairo-cairo-t.html#cairo-antialias-t">cairo_antialias_t</a>
  38. </li>
  39. <li><b>GRASS_RENDER_FILE=filename</b><br>
  40. the name and format of the resulting image file, default is
  41. <tt>map.png</tt>.<br>
  42. The image format is determined from the file extension.<br>
  43. Supported bitmap formats:
  44. <ul>
  45. <li><b>.png</b> - Portable Network Graphics (PNG)</li>
  46. <li><b>.bmp</b> - Windows Bitmap (BMP, 32-bpp)
  47. (these are not readable by some older viewers)</li>
  48. <li><b>.ppm</b> - Portable Pixmap (PPM + PGM for alpha channel)</li>
  49. </ul>
  50. Supported vector formats:
  51. <ul>
  52. <li><b>.pdf</b> - Portable Document Format (PDF)</li>
  53. <li><b>.ps</b> - PostScript (PS)</li>
  54. <li><b>.svg</b> - Scalable Vector Graphics (SVG)</li>
  55. </ul>
  56. (Note: Some formats may not be available, depending on your platform and
  57. the Cairo library that GRASS was built with.)
  58. </li>
  59. <li><b>GRASS_RENDER_FILE_READ</b><br>
  60. if <tt>TRUE</tt>, the Cairo driver will initialize the image from
  61. the contents of GRASS_RENDER_FILE.<br>
  62. (<em>Note: This is only supported for bitmap formats</em>)
  63. </li>
  64. <li><b>GRASS_RENDER_FILE_MAPPED</b><br>
  65. if <tt>TRUE</tt>, the Cairo driver will map GRASS_RENDER_FILE as its framebuffer,
  66. rather than using memory.<br>
  67. (<em>Note: This only works with BMP files.</em>)
  68. </li>
  69. <li><b>GRASS_RENDER_CAIRO_SCREEN</b><br>
  70. defines Cairo screen
  71. </li>
  72. <li><b>GRASS_RENDER_CAIRO_VISUAL</b><br>
  73. defines Cairo visual
  74. </li>
  75. </ul>
  76. <h2>EXAMPLES</h2>
  77. <h3>PNG Example</h3>
  78. Example: using the driver to generate a PNG file (bash-syntax):
  79. <div class="code"><pre>
  80. export GRASS_RENDER_IMMEDIATE=cairo
  81. export GRASS_RENDER_FILE=nc_spm.png
  82. export GRASS_RENDER_WIDTH=800
  83. export GRASS_RENDER_HEIGHT=800
  84. export GRASS_RENDER_FILE_READ=TRUE
  85. g.region raster=elevation
  86. d.rast map=elevation
  87. d.vect map=streams width=1 color=blue fcolor=aqua type=area,line
  88. d.vect map=roadsmajor width=2
  89. </pre></div>
  90. <h3>PDF Examples</h3>
  91. Example: using the driver to generate a PDF vector file with a vector
  92. map (bash-syntax):
  93. <div class="code"><pre>
  94. export GRASS_RENDER_IMMEDIATE=cairo
  95. export GRASS_RENDER_FILE=nc_spm.pdf
  96. export GRASS_RENDER_WIDTH=800
  97. export GRASS_RENDER_HEIGHT=800
  98. g.region vector=roadsmajor
  99. # activate vector font
  100. d.font Vera
  101. d.vect map=roadsmajor layer=1 display=shape attrcolumn=ROAD_NAME lcolor=0:90:255
  102. </pre></div>
  103. <p>
  104. Example: using the driver to generate a PDF raster file with a raster
  105. map (bash-syntax):
  106. <div class="code"><pre>
  107. export GRASS_RENDER_IMMEDIATE=cairo
  108. export GRASS_RENDER_FILE=nc_spm.pdf
  109. export GRASS_RENDER_WIDTH=800
  110. export GRASS_RENDER_HEIGHT=800
  111. g.region raster=elevation
  112. d.rast map=elevation
  113. </pre></div>
  114. <h3>SVG Example</h3>
  115. Example: using the driver to generate a SVG vector file with a vector
  116. map (bash-syntax):
  117. <div class="code"><pre>
  118. export GRASS_RENDER_IMMEDIATE=cairo
  119. export GRASS_RENDER_FILE=vectormap.svg
  120. g.region vector=roadsmajor
  121. d.vect map=roadsmajor -c
  122. </pre></div>
  123. <h2>NOTES</h2>
  124. The driver is still in development. Enable it by specifying
  125. <code>--with-cairo</code> when configuring GRASS. This
  126. requires a reasonably recent version of the Cairo libraries
  127. and a working <tt>pkg-config</tt>.
  128. <p>Antialiasing is enabled by default for bitmap formats. There is
  129. currently no way of disabling this.
  130. <p>The resolution of the output images is defined by current region
  131. extents. Use <tt>g.region -p</tt> to get the number of rows and cols
  132. and use the environment variables to set the image size. If you would
  133. like a larger image, multiply both rows and cols by the same whole
  134. number to preserve the aspect ratio.
  135. <p>Cairo supports true vector format output whenever possible. However,
  136. if the selected format doesn't support a necessary feature, Cairo may
  137. fall back on rendering a bitmap representation of the image wrapped in
  138. the selected vector format.
  139. <h2>SEE ALSO</h2>
  140. <em>
  141. <a href="pngdriver.html">PNG driver</a>,
  142. <a href="psdriver.html">PS driver</a>,
  143. <a href="htmldriver.html">HTML driver</a>,
  144. <a href="variables.html">variables</a>
  145. </em>
  146. <p>
  147. <em>
  148. <a href="d.rast.html">d.rast</a>,
  149. <a href="d.vect.html">d.vect</a>,
  150. <a href="d.mon.html">d.mon</a>,
  151. <a href="d.erase.html">d.erase</a>,
  152. <a href="d.redraw.html">d.redraw</a>
  153. </em>
  154. <h2>AUTHOR</h2>
  155. Lars Ahlzen &lt;<i>lars (at) ahlzen.com</i>&gt;<br>
  156. and the GRASS Development Team.
  157. <p>
  158. <i>Last changed: $Date$</i>