Programming and Graphics

(Kiana) #1

228 Introduction to C++ Programming and Graphics


Figure 7.5.1 Graphics display produced by codeplot2dshowing a line with markers
at the data points and complete axes.

The graphics output of the code is shown in Figure 7.5.1.


Preparing a postscript file


Now we would like to see a graph on the screen and, if approved, pro-
duce a postscript file that can be sent to a printer or included in a document.
Vogleallows us to do this efficiently by repeating the graph with “postscript”
as the output device and a specified file name as the recipient. The necessary
modifications are shown in the following code:


/*------------------------
plot2d
Plot a function with axis
and generate a postscript file
-------------------------*/

#include<iostream>
#include<cmath>
#include "VOGLE/voglec++.h"
#include "drawmarker2d.h"
#include "drawline2d.h"
#include "drawaxes2d.h"
using namespace std;

char kbd;
Free download pdf