This program draws a star or polygon figure by plotting lines from the centre of the screen outward to equally spaced points around a circle of radius 85 pixels. The user inputs the number of lines and whether OVER mode is active, allowing overlapping lines to erase each other for interesting visual effects. Each spoke is calculated using trigonometry: angles are distributed evenly as 2π divided by the number of lines requested. The fixed centre point is PLOT 128,88, placing it near the middle of the 256×176 pixel display area.
Program Analysis
Program Structure
The program is short and linear, consisting of an input phase, a single drawing loop, and a cleanup step. There are no subroutines; all logic fits within 12 lines.
- Lines 10–15: Collect user inputs for OVER mode (
o) and line count (l), then applyOVER o. - Lines 20–30: Copy
lintolinesand initialise the starting anglea=0and the angular stepangle=2*PI/lines. - Lines 40–100: The main
FORloop iterateslinestimes, computing an endpoint withCOS/SIN, then drawing a spoke from the fixed centre (128,88). - Lines 110–120: Reset
OVER 0to restore normal drawing mode before stopping.
Drawing Geometry
Every spoke starts at pixel (128, 88), which is approximately the centre of the 256×176 display. The endpoint is computed as a displacement:
x = 85 * COS ay = 85 * SIN a
A radius of 85 pixels keeps all endpoints well within the screen boundary. Angles are stepped by 2*PI/lines, so the spokes are always perfectly evenly distributed regardless of how many lines are requested.
OVER Mode Usage
The OVER flag controls how drawn pixels interact with existing screen content. With OVER 1, each pixel is XORed against the display, meaning where two lines cross they cancel out, producing distinctive star or asterisk effects. With OVER 0, lines simply overwrite. Resetting OVER 0 at line 110 ensures the graphics mode is left in a clean state after the program ends.
Notable Techniques
- The redundant variable
lines(line 20) mirrors the inputlwithout adding functionality;lcould have been used directly in theFORstatement and the angle calculation. - Using
PLOTfollowed byDRAW(rather than twoPLOT/DRAWcalls with absolute coordinates) is a standard idiom for drawing lines from a fixed origin. - The angle accumulator
ais incremented additively each iteration rather than recomputed asi * angle, which is slightly faster but can accumulate floating-point rounding error over many iterations.
Potential Issues
- No input validation is performed: entering
lines=0would cause a division-by-zero error at line 30. - A large radius of 85 combined with certain angle values may cause
DRAWto attempt plotting outside the screen boundary, generating an error. In practice most line counts are safe, but edge cases exist near the corners. - The prompt limits OVER to 1 or 0 by convention only; any integer value is accepted by the interpreter.
Content
Source Code
10 INPUT " OVER (1 OR 0) ";o: INPUT " LINES ";l
15 OVER o
20 LET lines=l
30 LET a=0: LET angle=2*PI/lines
40 FOR i=1 TO lines
50 LET x=85*COS a
60 LET y=85*SIN a
70 PLOT 128,88
80 DRAW x,y
90 LET a=a+angle
100 NEXT i
110 OVER 0
120 STOP
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
