Circle Squared

Developer(s): Mel R. Richardson
Date: 1986
Type: Program
Platform(s): ZX81, TS 1000
Tags: Graphics

“Wallpaper for the mind”: for each point of a 170 by 120 pixel area it works out X²+Y² and plots the point when the whole-number part is even, which gives a pattern of circles over an underlying grid of squares that never quite repeats. Mel Richardson based it on John E. Connett’s program in A.K. Dewdney’s Computer Recreations column (Scientific American, September).

Enter CORNA and CORNB (the lower left corner) and SIDE (the size; smaller magnifies), for example -15, -20, 87 or -30, 5, 40 or 20, -10, 20. Z copies the screen to the printer and R starts again.

Written for a ZX81 with the Oliger video upgrade and JOBASIC: every PRINT, INPUT, PLOT and COPY goes through IF USR M2 THEN, and the set-up lines before line 10 are left for your system, so as printed it does not run on a stock ZX81. The article says a ZX81 with Graphica, or a TS2068, can run it with those lines changed.

Published in Sinc-Link November-December 1986 (Circle Games).

Related Articles

Type-in program for JOBASIC or other high resolution routine to draw patterns with circles.

Image Gallery

Source Code

   2 REM CIRCLE SQUARED
   3 REM
   4 REM JOBASIC,GRAPHICA OR OTHER HI-RES INITIALIZTION HERE
   5 REM
   8 REM INPUT VARIABLES
  10 IF USR M2 THEN PRINT "CORNA? ";
  12 IF USR M2 THEN INPUT CORNA
  14 IF USR M2 THEN PRINT "CORNB? ";
  16 IF USR M2 THEN INPUT CORNB
  18 IF USR M2 THEN PRINT "SIDE? ";
  20 IF USR M2 THEN INPUT SIDE
  25 REM 170X120 PIXEL DISPLAY
  30 FOR I=1 TO 170
  40 FOR J=1 TO 120
  60 LET X=CORNA+(SIDE*I/100)
  70 LET Y=CORNB+(SIDE*J/100)
  80 LET Z=X*X+Y*Y
  90 LET C=INT Z
  92 REM
  95 REM TEST FOR EVENESS
 100 LET E=C/2-INT (C/2)
 110 IF NOT E THEN IF USR M2 THEN PLOT I+40,J+36
 120 NEXT J
 130 NEXT I
1000 IF USR M2 THEN PRINT AT 23,0;"Z-COPY  R-RESTART"
1010 IF INKEY$="" THEN GOTO 1000
1020 IF INKEY$="Z" THEN IF USR M2 THEN COPY
1022 IF INKEY$="R" THEN RUN
1025 GOTO 1000

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