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