Lines

Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v5 n3 (Volume 5, Issue 3)
Date: March 1984
Pages: 10

Here’s a program that counts on simple math to produce a random display of fans of color. It works by picking two pairs of points on the screen and drawing a series of lines between them. It leaves them on the screen for a while and then quietly picks up after itself.

Sample fan of lines drawn by the program
Sample fan of lines drawn by the program
  10 LET T=30
15 LET P=1
20 DIM E(T)
30 DIM F(T)
40 DIM G(T)
50 DIM H(T)
60 DIM X(2,2)
70 DIM Y(2,2)
80 BORDER 0: PAPER 0: INK 7: OVER 0
90 CLS
100 FOR S=1 TO 2
110 FOR Q=1 TO 2
120 LET X(S,Q)=RND*255
130 LET Y(S,Q)=RND*175
140 NEXT Q
150 NEXT S
160 LET S=T/2
200 LET TX=(X(1,2)-X(1,1))/S
210 LET TY=(Y(1,2)-Y(1,1))/S
220 LET BX=(X(2,2)-X(2,1))/S
230 LET BY=(Y(2,2)-Y(2,1))/S
300 LET B=Y(1,1)
310 LET C=X(2,1)
320 LET D=Y(2,1)
330 FOR A=X(1,1) TO X(1,2) STEP TX
400 LET E(P)=A
410 LET F(P)=B
420 LET G(P)=C-A
430 LET H(P)=D-B
440 LET P=P+1
450 IF P>T THEN LET P=1
460 PLOT INVERSE 1;E(P),F(P)
470 DRAW INVERSE 1;G(P),H(P)
480 PLOT A,B
490 DRAW C-A,D-B
500 LET B=B+TY
510 LET C=C+BX
520 LET D=D+BY
530 NEXT A
540 INK RND*6+1
600 FOR Q=1 TO 2
610 LET X(Q,1)=X(Q,2)
620 LET Y(Q,1)=Y(Q,2)
630 LET X(Q,2)=RND*255
640 LET Y(Q,2)=RND*175
650 NEXT Q
700 GO TO 200
SYNTACTIC SUM: 44026, TS2068

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