The Plotter: Tips and Programs for the Plotter User

See all articles from CATS v5 n9
Author(s): Peter van Dijk
Publication: CATS Newsletter
Pub Details: CATS v5 n9 (Volume 5, Issue 9)
Date: January 1988
Pages: 4, 11

A few remarks on program PLOT2.

The program produces a few pretty pictures on the screen and can plot them on the EPSON HI-80. The procedures for the pictures are simple nested loops, doing some basic mathematical calculations to determine coordinates. The program proves that a few lines of SUPERBASIC can produce nice graphics.

Some explanations on the program.

LINE 130: Sets a scale that matches the paper size and unit system of the plotter,so no scaling is required in the plotter commands.

LINE 270: Opens a channel to the plotter. If this line is replaced by line 280 (as in the present program), all plotter commands are sent to a window on the screen. This is useful when debugging programs or if you want to run the program without a plotter. If a printer is connected to SER2 a hard copy of the plotter commands is produced.

LINES 710 and 740 draw lines from an odd number of points on a circle, leaving a “hole” in the middle of the picture. If lines 700 and 730 are used instead, the “hole” is closed.

As the plotter units are integers, the INT function is used for calculations of numbers sent to the plotter.

LINES 860 to 930 are the procedures that transfer the plotter commands DF, MA, etc. in proper format to channel#3.

To use the program for screen output only, the following lines have to be removed: 270,280,290,410,530,620,640,770,830

100 REMark PICTURES WITH EPSON H
I-80
110 REMark DECEMBER 1987 PETER V
AN DIJK
120 WINDOW 512,256,0,0:PAPER 0
130 SCALE 2000,-1600,-1000
140 REPeat PROGRAM
150 CLS:AT 10 ,20:PRINT '1) SQUAR
ES':PRINT TO 20,'2) CIRCLES'
160 PRINT TO 20,'3) TRIANGLES':PR
INT TO 20,'4) STARS':PRINT TO 20,
'0) STOP';
170 INPUT TO 50,KEY:CLS
180 OPENER
190 SELect ON KEY
200 =1:SQUARES:=2:CIRCLES:=3:TRIA
NGLES:=4:STARS:=0:CLOSER:STOP
210 END SELect
220 CLOSER
230 PAUSE
240 END REPeat PROGRAM
250 REMark **********************
***
260 DEFine PROCedure OPENER
270 REMark OPEN#3,SER2h:SP KEY:RE
Mark < OPEN PLOTTER CHANNEL >
280 OPEN#3,CON:WINDOW #3,80,256,0
,0:CLS#3:REMark < PLOTTER COMMAND
S TO SCREEN ONLY >
290 MA 1255,960:OR1
300 END DEFine OPENER
310 REMark **********************
*****
320 DEFine PROCedure SQUARES
330 FACTOR=1:ANGLE=0:INCR=RAD(3)

340 REPeat ROTATION
350 RESTORE 460
360 FOR CORNER=1 TO 5
370 READ X,Y
380 X1=INT(FACTOR*(X*COS(ANGLE)+Y
*SIN(ANGLE)))
390 Y1=INT(FACTOR*(Y*COS(ANGLE)-X
*SIN(ANGLE)))
400 IF CORNER=1:LINE X1,Y1:ELSE :
LINE TO X1,Y1:END IF
410 IF CORNER=1:MA X1,Y1:ELSE :DA
X1,Y1:END IF
420 END FOR CORNER
430 ANGLE=ANGLE+INCR:FACTOR=FACTO
R*.95
440 IF ANGLE>=.75*PI:RETurn :END
IF
450 END REPeat ROTATION
460 DATA -900,900,900,900,900,-90
0,-900,-900,-900,900
470 END DEFine SQUARES
480 REMark **********************
******
490 DEFine PROCedure CIRCLES
500 FOR LOOP =PI/25 TO 2*PI STEP
PI/25
510 X=INT(400*COS(LOOP)):Y=INT(40
0*SIN(LOOP))
520 CIRCLE X,Y,500
530 CA X,Y,500,0,3600
540 END FOR LOOP
550 END DEFine CIRCLES
560 REMark **********************
*****
570 DEFine PROCedure TRIANGLES
580 FOR RADIUS=800 TO 400 STEP -2
00
590 FOR LOOP=4E-2*PI*(200/RADIUS)
TO 2*PI STEP 4E-2*PI*(200/RADIUS
)
600 X=INT(RADIUS*SIN(LOOP)):Y=INT
(RADIUS*COS(LOOP))
640 DR 200,100:DR 0,-200:DR -200,
100
650 END FOR LOOP
660 END FOR RADIUS
670 END DEFine TRIANGLES
680 REMark **********************
*****
690 DEFine PROCedure STARS
700 REMark FOR POINT1 =.1*PI TO 2
*PI STEP .1*PI
710 FOR POINT1 =2*PI/19 TO 2*PI S
TEP 2*PI/19
720 X=INT(900*COS(POINT1)):Y=INT(
900*SIN(POINT1))
730 REMark FOR POINT2=POINT1+.1*P
I TO 2*PI STEP .1*PI
740 FOR POINT2=POINT1+2*PI/19 TO
2*PI STEP 2*PI/19
750 X1=INT(900*COS(POINT2)):Y1=IN
T(900*SIN(POINT2))
760 LINE X,Y TO X1,Y1
770 MA X,Y:DA X1,Y1
780 END FOR POINT2
790 END FOR POINT1
800 END DEFine STARS
810 REMark *********************

820 DEFine PROCedure CLOSER
830 DF:CH:CLOSE#3
840 END DEFine CLOSER
850 REMark **********************

860 DEFine PROCedure DF:PRINT#3,'
DF':END DEFine
870 DEFine PROCedure MA(I,J):PRIN
T#3,'MA ';I;',';J:END DEFine
880 DEFine PROCedure DA(I,J):PRIN
T#3,'DA ';I;',';J:END DEFine
890 DEFine PROCedure DR(I,J):PRIN
T#3,'DR ';I;',';J:END DEFine
900 DEFine PROCedure OR1:PRINT#3,
'OR ':END DEFine
910 DEFine PROCedure CH:PRINT#3,'
CH':END DEFine
920 DEFine PROCedure CA(A,B,R,A1,
A2):PRINT#3,'CA ';A;',';B;',';R;'
,';A1;',';A2:END DEFine
930 DEFine PROCedure SP(P):PRINT#
3,'SP ';P:PRINT#3:END DEFine

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.