GraphicDemo

Developer(s): John Copps
Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Demo

This program draws a continuously shrinking diamond-like geometric pattern using the PLOT and DRAW commands. Starting with parameters a=5 and b=75, it repeatedly draws four line segments that form a closed quadrilateral, then decrements both values by 1 each iteration. The INK colour alternates between red (INK 2) and green (INK 4) for successive pairs of lines, creating a two-tone effect. A PAUSE 15 slows each iteration slightly, and the loop runs indefinitely via GO TO 6 until interrupted.


Program Analysis

Program Structure

The program is a straightforward infinite loop with no subroutines. After initialisation and a printer listing at lines 1–5, execution cycles through lines 6–90 repeatedly. The structure can be summarised as:

  1. Lines 1–4: REMs and printer output (LLIST/LPRINT)
  2. Line 5: Initialise variables a=5, b=75
  3. Lines 6–8: Display current parameter values on screen
  4. Lines 10–50: PLOT a starting point and DRAW a four-sided closed figure
  5. Lines 60–70: Decrement both a and b by 1
  6. Lines 80–90: Pause briefly and loop back to line 6
  7. Line 100: COPY (dead code — never reached)

Geometry of the Shape

Each iteration draws a quadrilateral from a fixed start point (225, 90) using four DRAW segments:

LineDRAWINKDirection
20DRAW a, b2 (red)up-right
30DRAW a, -b2 (red)down-right
40DRAW -a, -b4 (green)down-left
50DRAW -a, b4 (green)up-left

Because the horizontal extent is a and the vertical extent is b, and since b starts at 75 (much larger than a=5), the shape is a very tall, narrow diamond. Each loop iteration shrinks both dimensions by 1, causing the figure to collapse toward a vertical line as a approaches zero after 5 iterations, while b still has 70 iterations remaining before it too reaches zero.

Notable Techniques

  • Colour split within a shape: INK is changed between lines 30 and 35, so the right two edges are drawn in red and the left two in green, bisecting the diamond by colour.
  • AT-positioned parameter display: Lines 7–8 use PRINT AT to show the current values of a and b at fixed screen positions, updating them each pass without clearing the whole screen.
  • PAUSE 15: Introduces a brief delay (approximately one third of a second at 50 Hz) to make the animation visible rather than a blur.
  • Dead code at line 100: The COPY command is never reached because the GO TO 6 loop has no exit condition.

Potential Anomalies

  • Once a drops below zero (after iteration 6), the DRAW calls use negative a values, mirroring the shape horizontally. The loop never terminates, so b will eventually go negative too, producing increasingly unusual figures.
  • The PLOT at line 10 executes only once (before the first iteration of the loop), so subsequent iterations continue drawing from wherever the pen was left, not from (225, 90). This means the shapes are chained rather than redrawn from a fixed origin each time.
  • Lines 4 (LLIST/LPRINT) execute unconditionally on every run, which will send the program listing to the printer before the graphical loop begins.

Content

Appears On

One of a series of library tapes. Programs on these tapes were renamed to a number series. This tape contained

Related Products

Related Articles

Related Content

Image Gallery

GraphicDemo

Source Code

    1 REM "GRAPHIC ?"
    2 REM By John Copps
    4 LLIST : LPRINT 
    5 LET a=5: LET b=75
    6 INK 2
    7 PRINT AT 2,6;"a=";a
    8 PRINT AT 2,20;"b=";b
   10 PLOT 225,90
   20 DRAW a,b
   30 DRAW a,-b
   35 INK 4
   40 DRAW -a,-b
   50 DRAW -a,b
   60 LET a=a-1
   70 LET b=b-1
   80 INK 4: PAUSE 15
   90 GO TO 6
  100 COPY 

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

Scroll to Top