BBC B Tapestry

At the beginning the program prompts for the number of seeds. If you choose one seed it is placed in the centre of the screen. Multiples of four seeds are positioned regularly around two axes, other even numbers are positioned regularly around one axis. Odd numbers of seeds are scattered randomly in a central area of the screen.

After pressing 'Return' the growth begins immediately. The sequence and number of colours is chosen randomly by the computer. The pattern will stop when it reaches the edge of the screen.

Code: Select all

```
10 MODE130
20 G%=420
30 DIM A%(G%),B%(G%),C%(G%),D%(G%),U%(15)
40 *FX9,255
50 *FX10,255
60 PRINTTAB(0,5)"SPACE BAR -":PRINT
70 PRINT"STOP AND START"
80 PRINTTAB(0,12)"'E' - END"
90 INPUTTAB(0,20)"NUMBER OF SEEDS",O%
100 VDU23,0,10,32,0;0;0;
110 K%=RND(15)
120 FORN%=1TOK%
130 U%(N%)=RND(15)
140 NEXT
150 J%=8:ST%=0:P1%=0:P2%=0:P3%=0
160 CLG
170 VDU29,640;512;
180 GCOL0,U%(K%)
190 E%=0
200 IFO%=1THENPROCSQ(0,0):PROCPATTERN
210 IFO% MOD4=0THENPROCFOUR
220 IFO% MOD2=0THENPROCEVEN
230 FORN%=1TOO%
240 P%=FNRAND:Q%=FNRAND
250 PROCSQ(P%,Q%)
260 NEXT
270 PROCPATTERN
280 END
290 DEFPROCFOUR
300 O%=O%/4
310 FORN%=1TOO%
320 P%=FNRAND:Q%=FNRAND
330 PROCSQ(P%,Q%)
340 PROCSQ(-P%,-Q%)
350 PROCSQ(-P%,Q%)
360 PROCSQ(P%,-Q%)
370 NEXT
380 PROCPATTERN
390 ENDPROC
400 DEFPROCEVEN
410 O%=O%/2
420 FORN%=1TOO%
430 P%=FNRAND:Q%=FNRAND
440 PROCSQ(P%,Q%)
450 PROCSQ(-P%,-Q%)
460 NEXT
470 PROCPATTERN
480 ENDPROC
490 DEFPROCPATTERN
500 REPEAT
510 FORC%=1TOK%
520 GCOL0,U%(C%)
530 FORF%=1TOE%:A%(F%)=C%(F%):B%(F%)=D%(F%):NEXT
540 L%=E%:E%=0
550 FORN%=1TOL%
560 X%=A%(N%):Y%=B%(N%)
570 P%=X%+J%:Q%=Y%+J%
580 P1%=POINT(P%-J%,Q%+J%):P2%=POINT(P%+J%,Q%+J%):P3%=POINT(P%+J%,Q%-J%)
590 PROCSQ(P%,Q%)
600 P%=X%+J%:Q%=Y%-J%
610 P1%=POINT(P%+J%,Q%-J%):P2%=POINT(P%+J%,Q%+J%):P3%=POINT(P%-J%,Q%-J%)
620 PROCSQ(P%,Q%)
630 P%=X%-J%:Q%=Y%-J%
640 P1%=POINT(P%-J%,Q%-J%):P2%=POINT(P%+J%,Q%-J%):P3%=POINT(P%-J%,Q%+J%)
650 PROCSQ(P%,Q%)
660 P%=X%-J%:Q%=Y%+J%
670 P1%=POINT(P%-J%,Q%+J%):P2%=POINT(P%+J%,Q%+J%):P3%=POINT(P%-J%,Q%-J%)
680 PROCSQ(P%,Q%)
690 NEXT
700 IFST%=1ORINKEY(0)=32THENW%=GET:IFW%=69THENCLS:GOTO60
710 NEXT
720 UNTILFALSE
730 ENDPROC
740 DEFPROCSQ(P%,Q%)
750 IFP1%+P2%+P3%>0GOTO800
760 IFP1%=-1ORP2%=-1ORP3%=-1 ST%=1
770 VDU25,4,P%+J%;Q%;:VDU25,4,P%;Q%+J%;:VDU25,85,P%;Q%-J%;:VDU25,85,P%-J%;Q%;
780 E%=E%+1:IFE%>G% THENE%=G%
790 C%(E%)=P%:D%(E%)=Q%
800 ENDPROC
810 DEFFNRAND=INT((200-RND(400))/(2*J%))*2*J%
```