--- title: "Clover" id: 56231 type: "computer_media" slug: "clover" url: "http://localhost/computer_media/clover/" markdown_url: "http://localhost/computer_media/clover.md" published_at: "2024-07-22T00:57:58+00:00" modified_at: "2026-03-30T21:41:29+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/07/SCR-20240721-rbgt.png" excerpt: "A mesmerizing geometric \"Clover\" pattern grows petal by petal with randomized colors and three distinct drawing modes, then floods the screen with fill lines before restarting." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" media_contents: - id: 56205 title: "CATS Library Tape 11" type: "computer_media" url: "http://localhost/computer_media/cats-library-tape-11/" media_type: "Program" download_url: "https://archive.org/download/timex-sinclair-software-archive/Clover%20%28198x%29%28TS2068%29%28US%29%28Program%29.zip" mediadate: "198x" images: - url: "http://localhost/wp-content/uploads/2024/07/SCR-20240721-rbgt.png" media_type_tags: "Demo" --- # Clover This program draws a geometric pattern called “Clover,” building overlapping diamond and square shapes arranged in a circular layout using PLOT and DRAW commands with arc parameters. It selects random ink, paper, and border colors at startup, avoiding colors 3–5 for the paper to ensure visibility. Three pattern modes (controlled by variable U) determine whether shapes are drawn as arcs, combined arcs and rectangles, or rectangles alone. After drawing the petal arrangement, the program floods the screen with vertical and horizontal fill lines in four passes before looping back to restart with an increased petal count. *** ## Program Analysis ### Program Structure The program is organized into three logical phases that loop indefinitely via `GO TO 545` at line `680`: 1. **Initialization** (lines 542–567): Sets brightness, chooses random colors, selects a pattern mode `U` and step increment `F`, draws a border rectangle. 2. **Main drawing routine** (lines 580–625): Iterates over `L` “petals” arranged around a central circle, drawing expanding diamond/square shapes at each angular position. 3. **Fill lines** (lines 635–680): Draws vertical and horizontal scan lines across the screen in four directional passes, pausing between each, then restarts the whole program. ### Color Selection The paper color `A1` is chosen randomly at line `546` but colors 3, 4, and 5 (cyan, green, magenta) are rejected at line `547` via a retry loop (`GO TO 546`), leaving black (0), blue (1), red (2), and white (7) as valid paper colors. `INK 9` selects transparent/contrast ink. `BORDER` is set to a random value each cycle. ### Pattern Modes Variable `U` is set to 1, 2, or 3 and controls which geometric primitives are drawn at each petal position: | U value | Shape drawn | | --- | --- | | 1 | Diamond arcs only (four-quadrant DRAW with angle `W=0`) | | 2 | Diamond arcs plus axis-aligned rectangles | | 3 | Axis-aligned rectangles only (lines 606–607 force `V=42`, skipping the arc loop) | ### Arc Drawing Technique The four-quadrant diamond at each petal is drawn at line `610` using `DRAW dx,dy,angle` with `W=0`, which produces straight lines (zero-radian arc). Each call plots a side of a rotated diamond: `DRAW V,-V,W`, `DRAW -V,-V,W`, `DRAW -V,V,W`, `DRAW V,V,W`. Lines `616–617` repeat the pattern with `V` incremented by 1 to add a slightly larger outline, giving a double-trace effect. ### Petal Positioning Each petal center is calculated using polar coordinates at lines `595–600`. The angle `A` steps from 0 to 2π over `L` iterations: `A = T / (L/2) * PI`. The center is placed at a fixed radius of 42 pixels from screen center (127, 87). The inner loop at line `605` expands `V` from `R` (a random starting radius 5–39) down to 42 in steps of `F` (1–6), creating layered concentric shapes. ### Mode 3 Single-Iteration Trick When `U=3`, lines `606–607` replace the normal `FOR V=R TO 42 STEP F` loop body with `FOR V=42 TO 42`, effectively forcing a single iteration at `V=42`. This is a clever inline conditional loop override — the outer `FOR` at line `605` is already entered, and the inner `FOR` at line `607` shadows `V` for one step, but because line `606` uses `GO TO 610` to skip line `607` when `U<3`, the inner loop only runs in mode 3. However, the `NEXT V` at line `620` will serve the outer loop in modes 1 and 2 and the inner loop in mode 3, which may cause the outer loop to continue unexpectedly after the inner `FOR` completes — a potential behavioral anomaly. ### Screen Fill Effect Lines `640–670` draw lines across the entire screen in four passes — left-to-right verticals, top-to-bottom horizontals, right-to-left verticals, and bottom-to-top horizontals — each separated by a `PAUSE G` (where `G=100` frames). The step size `B=2` leaves every other column/row undrawn, creating a striped overlay effect over the clover pattern. ### Loop Growth At line `630`, `L` is incremented by 2 each cycle, beginning at 6. This increases the number of petals drawn (and therefore the angular resolution of the circular arrangement) with each iteration. Since there is no cap on `L`, the petal count grows indefinitely, though in practice the pattern repeats visually once `L` becomes large relative to screen resolution. ### Notable Variables - `L` — petal count, starts at 6, increments by 2 each loop - `U` — drawing mode (1=arcs, 2=arcs+rects, 3=rects) - `R` — random starting radius for inner loop (5–39) - `F` — step size for expanding shapes (1–6) - `W` — arc angle parameter, fixed at 0 (straight lines) - `G` — pause duration in frames (100) - `B` — fill line spacing (2) ## Source Code ``` 5 REM CLOVER 500 REM 542 BRIGHT 1: LET L=6 545 CLS : OVER 1: RANDOMIZE 0 546 LET A1=INT (RND*8) 547 IF A1=3 OR A1=4 OR A1=5 THEN GO TO 546 548 PAPER A1 550 INK 9: BORDER RND*7 551 LET U=INT (RND*3)+1 552 REM SET U = 1 OR 2 OR 3 553 LET R=INT (RND*35)+5 555 CLS : LET B=2 560 LET G=100: LET V=42 565 LET W=0 566 LET F=INT (RND*6)+1 567 DRAW 0,175: DRAW 255,0: DRAW 0,-175: DRAW -255,0 570 REM MAIN ROUTINE 580 FOR T=1 TO L 585 LET V=42 590 LET A=T/(L/2)*PI 595 LET X=127+42*COS A 600 LET Y=87+42*SIN A 605 FOR V=R TO 42 STEP F 606 IF U<3 THEN GO TO 610 607 FOR V=42 TO 42 610 PLOT X,Y+V: DRAW V,-V,W: DRAW -V,-V,W: DRAW -V,V,W: DRAW V,V,W 615 IF U=2 THEN PLOT X,Y+V: DRAW V,0: DRAW 0,-2*V: DRAW 2*-V,0: DRAW 0,2*V: DRAW V,0 616 LET V=V+1: PLOT X,Y+V: DRAW V,-V,W: DRAW -V,-V,W: DRAW -V,V,W: DRAW V,V,W 617 IF U=2 THEN PLOT X,Y+V: DRAW V,0: DRAW 0,-2*V: DRAW 2*-V,0: DRAW 0,2*V: DRAW V,0 620 NEXT V 625 NEXT T: PAUSE G: 630 LET L=L+2 635 REM FILL LINES 640 INK 9: FOR J=1 TO 255 STEP B: PLOT J,0: DRAW 0,175: NEXT J 645 PAUSE G 650 FOR J=175 TO 1 STEP -B: PLOT 0,J: DRAW 255,0: NEXT J 655 PAUSE G 660 FOR J=255 TO 1 STEP -B: PLOT J,0: DRAW 0,175: NEXT J 665 PAUSE G 670 FOR J=0 TO 175 STEP B: PLOT 0,J: DRAW 255,0: NEXT J 680 PAUSE 150: GO TO 545 999 SAVE "clover" LINE 1 ```