7.2 Getting started withVogle 203
Graphics files
To generate a file containing the graphics, instead of initializing the
graphics device to X11, we initialize it to a different device. Postscript files
are generated by choosing the devices:
postscript ppostscript cps pcpswhere the prefix “p” stands for “portrait” and the prefix “c” stands for “color”.
The name of the graphics file is defined by inserting the vogle command:
voutput ("filename");wherefilenameis a chosen graphics file name. If we do not include this state-
ment, the postscript file will be printed on the screen as a text.
For example, to generate a postscript graphics file namedhello.ps,we
replace the statementvinit("X11")with the two statements:
voutput ("hello.ps");
vinit("pcps");written in this particular order. After execution, the filehello.pswill appear in
the current directory.
Vogleallows us to initialize the graphics device to one type, and then
change it to a different type, as will be discussed in later sections. This feature
allows us to draw a graph on the screen and, if approved, print it in a graphics
file.
The postscript file can be transformed into an encapsulated postscript
(eps) file using, for example, theps2epsifacility in Unix. The eps file may then
be inserted in a document, as was done in the typesetting of this book.
World coordinates
In the default screen coordinates, the horizontal and vertical variablesx
andyvary in the range (− 1 ,1) over the graphics window. To change the screen
coordinates into world coordinates that vary over a specified range, we use the
ortho2function.
The following code implemented in the fileelaiolado.ccintroduces world
coordinates, and then prints and underlines olive oil in Greek:
/*-------------------------------
PRINT A WORD IN WORLD COORDINATES
-------------------------------*/