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:
- Lines 1–4: REMs and printer output (LLIST/LPRINT)
- Line 5: Initialise variables
a=5,b=75 - Lines 6–8: Display current parameter values on screen
- Lines 10–50: PLOT a starting point and DRAW a four-sided closed figure
- Lines 60–70: Decrement both
aandbby 1 - Lines 80–90: Pause briefly and loop back to line 6
- 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:
| Line | DRAW | INK | Direction |
|---|---|---|---|
| 20 | DRAW a, b | 2 (red) | up-right |
| 30 | DRAW a, -b | 2 (red) | down-right |
| 40 | DRAW -a, -b | 4 (green) | down-left |
| 50 | DRAW -a, b | 4 (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 ATto show the current values ofaandbat 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
COPYcommand is never reached because theGO TO 6loop has no exit condition.
Potential Anomalies
- Once
adrops below zero (after iteration 6), the DRAW calls use negativeavalues, mirroring the shape horizontally. The loop never terminates, sobwill 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
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.
