The Plotter: Tips and Programs for the Plotter User

See all articles from CATS v5 n10
Author(s): Peter van Dijk
Publication: CATS Newsletter
Pub Details: CATS v5 n10 (Volume 5, Issue 10)
Date: February 1988
Pages: 10

EXPLANATION OF PROGRAM PLOT3.

This program draws turtle pictures to a monitor screen and to the EPSON HI-80 plotter.

The turtle procedures are based on the TURTLE_BAS program in the QUANTA library (disk 8). All the picture drawing routines are examples of SUPERBASIC recursive procedures. The program has a start menu and any keypress after a picture is drawn, will bring back this menu. The scale used for the screen drawings is chosen to match the plot size without need for rescaling.

Line 290 opens a channel to the plotter. If this line is replaced by line 310 the plotter commands are directed to a screen window for program testing. A plotter is not required after this change is made. To speed up screen drawing all plotter commands can be bypassed by deleting lines 180, 240, 420, 600, 780 and 900.

The program has 3 procedures for translating the SUPERBASIC turtle commands into x y coordinates, required for the plotter. Procedures P_TURN and P_TURNTO update the absolute drawing angle and reduce angles of more than 360 degrees to (360-alfa) degrees. The angle is used in procedure P_MOVE to calculate the next relative x and y coordinates.

100 REMark  TURTLE-PICTURES WITH EPSON HI-80
110 REMark PROCEDURES BASED ON "TURTLE_BAS", QUANTA LIBRARY (DISK 8)
120 WINDOW 512,236,0,0:PAPER 2
130 REPeat PROG
140 CLS:AT 10 ,20:PRINT '1) NESTED_TRI'
150 PRINT TO 20,'2) SNOWFLAKE':PRINT TO 20,'3) SIERPINSKI'
160 PRINT TO 20,'4) CEE':PRINT TO 20,'0) STOP';
170 INPUT TO 40,INV:CLS
180 OPENER
190 SELect ON INV
200 =1:TRIANGLES:=2:SNOWFLAKE 1600,4
210 =3:SIERPINSKI 30,5:=4:CEE:=0:STOP
220 =REMAINDER
230 END SELect
240 CLOSER
250 PAUSE
260 END REPeat PROG
270 REMark **********
280 DEFine PROCedure OPENER
290 OPEN#3,SER2:REMark < OPEN PLOTTER >
300 REMark < PLOTTER COMMANDS TO SCREEN ONLY >
310 REMark OPEN#3,CON:WINDOW #3,80,256,0,0:CLS#3:DF
320 PENDOWN:BETA=0
330 END DEFine OPENER
340 REMark **********
350 DEFine PROCedure CLOSER:CH:CLOSE#3:END DEFine
360 DEFine PROCedure MA(I,J):PRINT#3,'MA ';I;',';J:END DEFine
370 DEFine PROCedure DR(I,J):PRINT#3,'DR ';I;',';J:END DEFine
380 DEFine PROCedure CH:PRINT#3,'CH':END DEFine
390 REMark **********
400 DEFine PROCedure TRIANGLES
410 SCALE 1925,-500,-35:POINT 0,0:P_TURNTO 0
420 MA 100,20
430 NESTED_TRI 2112
440 END DEFine TRIANGLES
450 REMark **********
460 DEFine PROCedure NESTED_TRI(size)
470 LOCal count
480 IF size<50
490 RETurn
500 ELSE
510 FOR count=1 TO 3
520 NESTED_TRI (size/2)
530 P_MOVE size:P_TURN 120
540 END FOR count
550 END IF
560 END DEFine NESTED_TRI
570 REMark **********
580 DEFine PROCedure SNOWFLAKE (size,level)
590 SCALE 1920,-700,-475:POINT 0,0
600 MA 250,475
610 P_TURNTO 0
620 FOR count=1 TO 3
630 side size,level:P_TURN 120
640 END FOR count
650 END DEFine SNOWFLAKE
660 REMark **********

To be concluded next month


THE MISSING 3 LINES

610 LINE X,Y
620 MA X,Y
630 LINE_R TO 200,100 TO 0,-200 TO -200,100

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