The Computer Tutor: Simulating Draw & Circle on the TS 1000

Author(s): Gene G. Buza
Publication: Synchro-Sette
Pub Details: Synchro-Sette v3 n3 (Volume 3, Issue 3)
Date: March 1984
Pages: 9-10
The Computer Tutor heading art, tutor in mortarboard pointing at a computer
The Computer Tutor heading art, tutor in mortarboard pointing at a computer

Good morning, Class! Today’s session will be on screen graphics for the TS-1000.

Unlike the TS-2068, the 1000 does not have commands such as DRAW and CIRCLE. These commands can be simulated with routines, however, the hi-res graphics will be missing.

To simulate the DRAW command, enter the following program:

10 LET X=0
20 LET Y=X
100 INPUT XX
110 INPUT YY
120 LET A=X-XX
130 LET B=Y-YY
140 LET C=(A AND ABS A>=ABS
B)
+ (B AND ABS B>ABS A)
150 IF C=0 THEN LET C=.1
160 FOR N=0 TO C STEP SGN C
170 PLOT X+A/C*-N,Y+B/C*-N
180 NEXT N
190 LET X=X+A/C*-N
200 LET Y=Y+B/C*-N
210 GOTO 100

This routine starts the first plotted point at the lower left hand of the screen and is determined by the “X” and “Y” values in lines 10 and 20. These of course can be changed.

The inputs from lines 100 and 110 ask for the pixel position that the line is to be drawn to. The first input would be how many pixels from the left border (1 to 62) and the next input is for how many pixels from the bottom (1 to 42). Enter “20” and “10” for these inputs and a diagonal line will be plotted and the routine will recycle for the next inputs.

Now enter two new screen co-ordinates and a new line will be drawn from the last plotted pixel to the new destination. The starting pixel position of the new line is determined by lines 190 and 200 which reset the X/Y values.

Line 140 does all the hard mathematics and the program uses various trig functions which perform quite quickly compared to other IF/THEN comparison techniques that are commonly used.

Unlike the TS-2068 version of DRAW, this routine simply asks for the screen positions that the line is going to be plotted to and draws the line to that position from the end of the last line. With this method you will not accidentally draw a line off the screen where an error message will occur as long as you stay within the specified parameters.

By changing the following lines to read:

190 INPUT X
200 INPUT Y

you can start the new lines at any position you want.

But so much for straight lines (almost straight). What about curved lines, circles and ellipses? Enter the following simple program:

10 INPUT A
20 INPUT B
100 FOR I=0 TO 2*PI STEP
PI/30
110 PLOT 30+A*COS I,B+B*SIN I
120 NEXT I

Line 10 inputs the width of the ellipsoid and line 20 inputs the height. If the two inputs are the same, a circle will result.

Now, what about curves? If we look at line 100 we see the segment “2*PI”. This represents the circumference of the circle or ellipsoid. If the “2*” were missing, only half of the circle or ellipsoid would be plotted. If you wanted only a fraction of the ellipsoid to appear, add and change the following lines:

30 INPUT C
100 FOR I=0 TO 2*PI*C STEP
PI/30

The variable “C” would now determine the fraction of the ellipsoid to be plotted and would be entered with line 30 with an input between .1 and 1.

Class dismissed!

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