d.graph.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <h2>DESCRIPTION</h2>
  2. <em>d.graph</em>
  3. draws graphics that are described either from standard input (default),
  4. or within a file (if an <b>input</b> file name is identified on the
  5. command line). If graphics commands are entered from standard input,
  6. a <em>CTRL-d</em> is used to signal the end of input to <em>d.graph</em>.
  7. Coordinates are given either as a percentage of frame height and width
  8. (default) or in geographic coordinates (with the <b>-m</b> flag).
  9. <p>
  10. The program can be run interactively or non-interactively.
  11. The user can run the program completely non-interactively
  12. by specifying the name of a graphics file containing the
  13. <em>d.graph</em> graphics commands. If run non-interactively the
  14. <em>d.graph</em> command is saved to the display's dedraw history.
  15. The user can also elect to run the program partially interactively,
  16. by specifying any/all of the parameters <em>except</em>
  17. the graphics file <b>input=</b><em>name</em> parameter on the command line.
  18. In this case, <em>d.graph</em> will expect the user to input <em>d.graph</em>
  19. graphics commands from standard input (i.e., the keyboard) and
  20. will (silently) prompt the user for these graphics commands.
  21. <p>Alternately, the user can simply type <b>d.graph</b> on the command line,
  22. and be prompted for the values of all parameters<!-- (the user can still
  23. input graphics commands from either an input file or standard input
  24. using this form)-->. In this case, the user is presented with the standard
  25. GRASS GUI interface.
  26. <p>The default coordinate system used is 0-100 percent of the active frame
  27. in x and similarly 0-100 in y,
  28. regardless of the graphics monitor display frame size and aspect.
  29. The (0,0) location is the lower left corner of the active graphics
  30. monitor display frame. All values may be floating point.
  31. If the <b>-m</b> flag is given, geographic coordinates will be used instead.
  32. <h2>COMMANDS</h2>
  33. <p>The graphics language is simple, and uses the following commands:
  34. <br>
  35. <dl>
  36. <dd>[
  37. <a href="#comment">#</a>&nbsp;|
  38. <a href="#move">move</a>&nbsp;|
  39. <a href="#draw">draw</a>&nbsp;|
  40. <a href="#polygon">polygon</a>&nbsp;|
  41. <a href="#polyline">polyline</a>&nbsp;|
  42. <a href="#color">color</a>&nbsp;|
  43. <a href="#text">text</a>&nbsp;|
  44. <a href="#size">size</a>&nbsp;|
  45. <a href="#symbol">symbol</a>&nbsp;|
  46. <a href="#rotation">rotation</a>&nbsp;|
  47. <a href="#icon">icon</a>&nbsp;|
  48. <a href="#width">width</a>
  49. ]</dd>
  50. </dl>
  51. <dl>
  52. <dt><a name="comment"></a><b>#</b> <em>comment</em></dt>
  53. <dd>A line of comment which is ignored in the processing.</dd>
  54. <dt><a name="move"></a><b>move</b> <em>xpos ypos</em></dt>
  55. <dd>The current location is updated to <em>xpos ypos</em>.
  56. Unless the <b>-m</b> flag is used,
  57. values are stated as a percent of the active display frame's
  58. horizontal (<em>xpos</em>) and vertical (<em>ypos</em>) size,
  59. and may be floating point values. Values are between 0-100.
  60. <b>Note.</b> A space must separate <em>xpos</em> and <em>ypos</em>.</dd>
  61. <dt><a name="draw"></a><b>draw</b> <em>xpos ypos</em></dt>
  62. <dd>A line is drawn in the current color from the current location to the new
  63. location <em>xpos ypos</em>, which then becomes the current location.
  64. Unless the <b>-m</b> flag is used,
  65. values are stated as a percent of the active display frame's
  66. horizontal (<em>xpos</em>) and vertical (<em>ypos</em>) size,
  67. and may be floating point values. Values are between 0-100.
  68. <b>Note.</b> A space must separate <em>xpos</em> and <em>ypos</em>.</dd>
  69. <dt><a name="polygon"></a><b>polygon</b>
  70. <br>&nbsp;&nbsp;<em> xpos ypos</em>
  71. <br>&nbsp;&nbsp;<em> xpos ypos</em>
  72. <br>&nbsp;&nbsp;...</dt>
  73. <dd>The coordinates appearing beneath the word <em>polygon</em>,
  74. one pair per line,
  75. circumscribe a polygon that is to be filled with the current color.</dd>
  76. <dt><a name="polyline"></a><b>polyline</b>
  77. <br>&nbsp;&nbsp;<em> xpos ypos</em>
  78. <br>&nbsp;&nbsp;<em> xpos ypos</em>
  79. <br>&nbsp;&nbsp;...</dt>
  80. <dd>The coordinates appearing beneath the word <em>polyline</em>,
  81. one pair per line,
  82. circumscribe a polygon that is not to be filled with color.</dd>
  83. <dt><a name="color"></a><b>color</b> <em>color</em></dt>
  84. <dd>Sets the current color to that stated; subsequent graphics will be drawn
  85. in the stated color, until the current color is set to a different color.
  86. Options are <em>red</em>,
  87. <em>orange</em>,
  88. <em>yellow</em>,
  89. <em>green</em>,
  90. <em>blue</em>,
  91. <em>indigo</em>,
  92. <em>violet</em>,
  93. <em>brown</em>,
  94. <em>magenta</em>,
  95. <em>gray</em>,
  96. <em>white</em>,
  97. <em>black</em>,
  98. an R:G:B triplet (separated by colons),
  99. or the word "none" (draws in the default background color).</dd>
  100. <dt><a name="text"></a><b>text</b> <em>line-of-text</em></dt>
  101. <dd>The stated text is drawn at the current location using the current color,
  102. and the new current location is then positioned at the end of the text string.</dd>
  103. <dt><a name="size"></a><b>size</b> <em>xper yper</em></dt>
  104. <dd>Subsequent text will be drawn such that the text is
  105. <em>xper</em> percent of the graphics monitor display frame wide and
  106. <em>yper</em> percent of the frame high. By default, the text size is set to
  107. 5 percent of the active frame's width and 5 percent of the frame's height.
  108. If only one value is given, then that value will be used for both x and y
  109. scaling.
  110. <br>
  111. <b>Note.</b> A space must separate <em>xper</em> and <em>yper</em>.</dd>
  112. <dt><a name="symbol"></a><b>symbol</b> <em>type size xper yper [line_color [fill_color]]</em></dt>
  113. <dd>A symbol is drawn at the given size on the display monitor. The
  114. <em>xper</em> and <em>yper</em> options define the center of the icon and
  115. are given as a percentage of the display frame (<tt>0,0</tt> is lower left).
  116. The symbol can be any of those stored in <tt>$GISBASE/etc/symbol/</tt>
  117. (e.g. <i>basic/circle</i>) or stored in the user's mapset directory in the
  118. form <tt>$MAPSET/symbol/</tt><em>type/name</em>.
  119. The colors may be either a standard color name, an R:G:B triplet,
  120. or "none". If using an R:G:B triplet, each color value can range from 0-255.
  121. If not specified the default <em>line_color</em> is black and the default
  122. <em>fill_color</em> is grey.</dd>
  123. <dt><a name="rotation"></a><b>rotation</b> <em>angle</em></dt>
  124. <dd>Subsequent text and symbols will be drawn such that they are rotated
  125. <em>angle</em> degrees counter-clockwise from east.</dd>
  126. <dt><a name="icon"></a><b>icon</b> <em>type size x y</em></dt>
  127. <dd>Draws an icon of types <em>o</em>, <em>x</em>, or <em>+</em>
  128. with specified <em>size</em> (in %) at location <em>x,y</em>.
  129. Note: type <em>o</em> designates a square.</dd>
  130. <dt><a name="width"></a><b>width</b> <em>value</em></dt>
  131. <dd>Subsequent lines (including non-FreeType text) will be drawn with
  132. the given pixel thickness.
  133. <br>The default value is 0.</dd>
  134. </dl>
  135. <h2>EXAMPLES</h2>
  136. For an example use of <em>d.graph</em>, examine the contents of the
  137. command file <em><a href="grass_logo.txt">grass_logo.txt</a></em>
  138. located in the <em>d.graph</em> source code directory. It will draw the
  139. CERL GRASS logo using the <em>d.graph</em> graphing commands stored in the file.
  140. Note that the coordinates in the <em><a href="grass_logo.txt">grass_logo.txt</a></em> file were
  141. taken directly off an image drawn by hand on graph paper.
  142. <!-- formerly names "grass.logo.sh" in GRASS 5 code. -->
  143. <p>A dynamic example can be found in the <em>d.polar</em> shell script.
  144. <h3>Draw a "star" symbol at a given map coordinate</h3>
  145. <div class="code"><pre>
  146. echo "symbol basic/star 20 2264417 5413182 black red" | d.graph -m
  147. </pre></div>
  148. <h3>Split the screen into quadrants:</h3>
  149. <div class="code"><pre>
  150. d.frame -s full_screen
  151. d.graph &lt;&lt; EOF
  152. color 80:80:120
  153. polygon
  154. 0 49.75
  155. 0 50.25
  156. 100 50.25
  157. 100 49.75
  158. polygon
  159. 49.85 0
  160. 50.15 0
  161. 50.15 100
  162. 49.85 100
  163. EOF
  164. </pre></div>
  165. <h2>NOTES</h2>
  166. <em>d.graph</em> remembers the last screen location (<em>xpos ypos</em>) to which
  167. the user moved, even after the user erases the display frame.
  168. If the user runs <em>d.graph</em> repeatedly, and wishes to start anew with
  169. the default (xpos ypos) screen location, the user should <em>clear</em> the
  170. display frame between runs of <em>d.graph</em>.
  171. <h2>LIMITATIONS</h2>
  172. There are no automated ways of generating graphic images. It is anticipated
  173. that GRASS user sites will write programs to convert output from a resident
  174. graphics editor into GRASS <em>d.graph</em> format.
  175. (e.g. EPS -> <em>d.graph</em>, perhaps with the help of a
  176. <a href="http://www.pstoedit.net/">pstoedit</a> plugin)
  177. <h2>SEE ALSO</h2>
  178. <em>
  179. <a href="d.font.html">d.font</a>,
  180. <a href="d.labels.html">d.labels</a>,
  181. <!-- <a href="d.mapgraph.html">d.mapgraph</a>, superseded by -m -->
  182. <a href="d.polar.html">d.polar</a>,
  183. <a href="d.text.html">d.text</a>,
  184. <a href="d.where.html">d.where</a>
  185. </em>
  186. <h2>AUTHOR</h2>
  187. James Westervelt, U.S. Army Construction Engineering Research Laboratory
  188. <p>
  189. <i>Last changed: $Date$</i>