A SERVICE OF

logo

The program explained here is an overly simplified plotting
program. It is not efficient in its use of memory, nor is it very fast.
In fact, the BASIC language itself is not very suitable for graphics
programs of a very large scale. BASIC is just not fast enough to
handle the massive amounts of data required for graphics. But
despite its drawbacks, this program contains all the elements
required, and BASIC does provide an almost universally under-
stood format for communicating them.
First, this program allocates a section of memory to contain the
graphic image that will be created. In line 140 the DIM statement
defines the integer array BUFFER%( ). You will use each element
of this array to store one byte of graphics data. Each element of an
integer array can actually hold two bytes of graphics data, but
doing so would complicate the program. Therefore, we just have
to accept the inefficiency.
The figure that this program prints fits in an area two inches
square, and the BUFFER%( )
array uses about 32K of memory.
You can see that there is a lot of graphics data involved (even
considering the inefficiency).
Line 150 creates a vector array of the powers of two. These are
the values that are assigned to the nozzles in the print head. They
are used in creating the image in memory.
Line 160 sets the coordinate scale of the graphics image. Set-
ting both scale factors to 20 creates a grid 20 units on a side. Line
170 calculates the relationship between the coordinate grid and
the actual dots to be printed. This program uses the 24-dot triple-
density option, so the two-inch square has 360 dots in each direc-
tion.
Line 180 assigns mnemonic variables for use in the printing
routine.
Lines 220-270 calculate the curve to be plotted. The curve that
the sample program plots is a hypocycloid. This is the shape
generated by the path of a point on a circle that is rolling around
the inside of another circle. Line 220 assigns the radii of the fixed
and rolling circles, respectively. Line 230 assigns the starting
point of the curve (you will see why this is necessary in a mo-
ment). Line 240 calculates a constant that is used in the calcula-
tions.
81