Plotting Graphs; Shading A Graph - DEC VT55 Programming Manual

Table of Contents

Advertisement

Suggested BASIC-PL US Applications
C.3 PLOTTING GRAPHS
Because the VT55 is so often used to display graphs, it is usually convenient to have a separate function
prepared that performs all the necessary initialization, enabling, graph number selection, and display in
one step. The function FNV3, defined below, is suggested for this purpose.
15100
DEF FNV3(N%)
15110
D
=
FNV5(7%,0%,0%)
15120
D
=
FNV5 (8%,511 %,0%)
15130
D
=
FNV5(2%,I%+(C7%+1 %)*2%,(C7%+ 1%)*10%)
15140
D
=
FNV5(3%,-N%,0%)
15150
D
=
FNV50%,1 %-C7%,0%)
15160
FNEND
You should take note of the following unusual features of this function definition:
l.
Line 15120 draws a vector from the origin (0,0) to the bottom right corner (511,0). This is one of
the simpler techniques for erasing the previous graph for a particular graph number, since drawing
such a vector fills up the appropriate register of the VT55 graphic memory with 512 points, all of
which have a y value of O.
2.
Line 15130 uses the variable C7%, which is the internal variable that stores the current graph
number in use (C7%
=
0% or 1 %). You may recall from the introduction to Chapter 3 that you
should avoid using internal variables in your program. In this case, however, the variable C7% is
used in the program for the same purpose for which it is used internally. You should, of course, use
such internal variables with caution, because changing their numerical values would affect the sta-
tus of the display.
3.
Line 15140 is simply the standard FNV5 call for creating a graph from the array V5. In other
words, you should assign the values you want to graph to the array V5 before writing D
=
FNV3 to
create the graph. Line 15140 will then plot the first N% points from V5, starting with an
x
position
ofO.
4.
Line 15150 will switch the graphic display from Graph 0 to Graph 1 and back to Graph 0 again
automatically as FNV3 is called several times in the same program. The first time FNV3 is called
from your program, the graph will appear as Graph 0; the second time, as Graph 1; and so forth. If
a very large number of graphs are displayed, just remember that the even-numbered calls will cre-
ate Graph 1 and the odd-numbered calls will create Graph O.
C.4 SHADING A GRAPH
This section suggests another function, called FNV4 here, that "shades" a graph, converting it from a nor-
mal graph made up of points to a shaded graph.
15170
DEFFNV4
15180
D
=
FNV5(2%,1 %+0 %-C7%)*8%+8%,(l %-C7%)*2%+2%)
15190
FNEND
C-4

Advertisement

Table of Contents
loading

Table of Contents