--- title: "Tapestry" id: 57597 type: "computer_media" slug: "tapestry" url: "http://localhost/computer_media/tapestry/" markdown_url: "http://localhost/computer_media/tapestry.md" published_at: "2024-10-05T22:55:57+00:00" modified_at: "2026-04-03T07:58:17+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/10/tapestry.png" excerpt: "A mesmerising two-part display program that spirals block graphics inward then draws shrinking trig-based circles before looping forever." 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 1000" slug: "ts1000" taxonomy: "post_tag" url: "http://localhost/tag/ts1000/" model: - name: "Timex/Sinclair 1000" slug: "ts-1000" taxonomy: "model" url: "http://localhost/model/ts-1000/" genre: - name: "Demo" slug: "demo" taxonomy: "genre" url: "http://localhost/type/demo/" - name: "Entertainment" slug: "entertainment" taxonomy: "genre" url: "http://localhost/type/entertainment/" media_contents: - id: 56723 title: "Synchro-Sette February 1983" type: "computer_media" url: "http://localhost/computer_media/synchro-sette-february-1983/" media_type: "Program" mediadate: "February 1983" images: - url: "http://localhost/wp-content/uploads/2024/10/tapestry.png" media_type_tags: "Demo, Entertainment" --- This program draws two successive animations on screen: first, a rectangular spiral that fills the display by printing a randomly chosen block-graphic character along each side, shrinking inward with each pass; second, a series of concentric circles drawn using trigonometric PRINT AT positioning, stepping through 360 degrees in 10-degree increments for radii from 10 down to 2. The random character selection at line 5 (and again at line 240) picks from characters 128–138, with the high-bit toggle controlled by a Boolean expression `128*(RND<0.5)`, alternating between normal and inverse block graphics. After the circle animation completes, the screen pauses briefly, clears, and the whole program restarts via RUN. The spiral is driven by four boundary variables (A, B, D, E) that tighten each iteration, terminating when the left column meets or exceeds the right column. *** ## Program Analysis ### Program Structure The program divides into three logical phases: 1. **Initialisation (lines 1–5):** Sets the four boundary variables and picks an initial random display character. 2. **Rectangular spiral (lines 50–220):** Iteratively draws the four sides of a shrinking rectangle using `PRINT AT`, tightening the bounds each pass until the boundaries collapse. 3. **Concentric circles (lines 230–290):** Uses sine and cosine to place characters around circles of decreasing radius, followed by a pause, clear, and `RUN` to loop. ### Spiral Mechanism Four variables track the current rectangle: `A` (top row), `B` (bottom row), `D` (left column), `E` (right column). Each complete pass draws the left edge (top→bottom), the bottom edge (left→right), the right edge (bottom→top), and the top edge (right→left). After each pass, `B` and `E` shrink by 1 while `A` and `D` grow by 1, closing the rectangle inward. The termination condition at line 210 checks `D>=E`. ### Character Selection Technique Line 5 generates `Z$` with the expression `CHR$ (INT (RND*11+128*(RND<0.5)))`. This selects a character code in the range 128–138 (the block graphic set). The sub-expression `128*(RND<0.5)` evaluates the Boolean comparison as 1 or 0, multiplies by 128, and thereby randomly chooses between the normal block graphic range (128–138) and, when zero, codes 0–10 — effectively producing either a block graphic or a control/space character. The same expression is reused at line 240 for each concentric ring, giving each circle a distinct random character. ### Trigonometric Circle Drawing Lines 250–280 loop `A` from 0 to 360 in steps of 10 degrees. The angle is converted to radians at line 260 as `B=A*PI/180`, then `PRINT AT 10+C*COS B, 15+C*SIN B` places the character around a circle of radius `C` character cells, centred approximately at row 10, column 15. The outer loop runs `C` from 10 down to 2, so circles are drawn largest-first. ### Variable Reuse The variables `A` and `B`, used as boundary coordinates in the spiral phase, are repurposed in the circle phase (lines 250–280) as the angle counter and the radian value respectively. This is intentional economy rather than a bug, since the spiral phase has completed before these lines are reached. ### Key BASIC Idioms - `128*(RND<0.5)` — Boolean-as-integer multiplication to conditionally add an offset. - `STEP -1` on `FOR` loops to traverse edges in reverse (lines 110, 170). - `RUN` at line 320 for an infinite loop, reinitialising all variables cleanly. - `PAUSE 200` (≈3.5 seconds) providing a brief rest between the two animation phases. ### Variable Summary | Variable | Spiral phase role | Circle phase role | | --- | --- | --- | | `A` | Top row boundary | Angle counter (degrees) | | `B` | Bottom row boundary | Angle in radians | | `C` | Loop counter for each edge | Circle radius (10→2) | | `D` | Left column boundary | Unused | | `E` | Right column boundary | Unused | | `Z$` | Character to print | Character to print | ## Source Code ``` 1 LET A=0 2 LET B=21 3 LET D=0 4 LET E=31 5 LET Z$=CHR$ (INT (RND*11+128*(RND<0.5))) 50 FOR C=A TO B 60 PRINT AT C,D;Z$ 70 NEXT C 80 FOR C=D TO E 90 PRINT AT B,C;Z$ 100 NEXT C 110 FOR C=B TO A STEP -1 120 PRINT AT C,E;Z$ 130 NEXT C 140 LET B=B-1 150 LET D=D+1 160 LET E=E-1 170 FOR C=E TO D STEP -1 180 PRINT AT A,C;Z$ 190 NEXT C 200 LET A=A+1 210 IF D>=E THEN GOTO 230 220 GOTO 5 230 FOR C=10 TO 2 STEP -1 240 LET Z$=CHR$ (INT (RND*11+128*(RND<0.5))) 250 FOR A=0 TO 360 STEP 10 260 LET B=A*PI/180 270 PRINT AT 10+C*COS B,15+C*SIN B;Z$ 280 NEXT A 290 NEXT C 300 PAUSE 200 310 CLS 320 RUN 9998 SAVE "TAPESTR%Y" 9999 RUN ```