' This program exported from BASIC Anywhere Machine (Version [5.2.3].[2023.12.16.16.28]) on 2024.05.18 at 14:16 (Coordinated Universal Time)
' Peter McGavin's GW-BASIC port of Richard Russell's BBC BASIC flower tessellation program.
' Works without any changes in BAM
' However, BAM's screen 9 does not handle text particularly well, so changed the screen mode to 12, using custom screen dimensions (line 10)

' 10 SCREEN 9: CLS: REM KEY OFF
10 SCREEN _NEWIMAGE(520,350,12): CLS
 20 T = TIMER
 30 SIZE = 28
 40 RINGS = 5
 50 XC = 320: YC = 175: XS = YC / 720: YS = YC / 720
 60 PI = 4 * ATN(1)
 70 DIM XX(8), YY(8), x(8), y(8), xp(8), yp(8)
 80 S = COS(36 * PI / 180)
 90 YMUL = SIZE / SIN(36 * PI / 180)
100 XX(0) = 0:   XX(1) = -1:  XX(2) = -1:  XX(3) = 0
110 XX(4) = 1:   XX(5) = 1:   XX(6) = 0:   XX(7) = 0:    XX(8) = 0
120 YY(0) = 0:   YY(1) = S:   YY(2) = 2+S: YY(3) = 2+2*S
130 YY(4) = 2+S: YY(5) = 1+S: YY(6) = 1:   YY(7) = 0:    YY(8) = 1.5+S
140 FOR I% = 0 TO 8: XX(I%) = XX(I%) * SIZE: YY(I%) = YY(I%) * YMUL: NEXT I%
150 FOR A% = 0 TO 9 : a = A% * PI/5
160   r00 = COS(a): r01 = -SIN(a): r10 = SIN(a): r11 = COS(a)
170   FOR Y% = 0 TO RINGS: y1 = Y% * YMUL * (1 + S)
180     FOR X% = Y% TO RINGS: x1 = (2*Y% - X%) * SIZE
190       IF Y% = 0 THEN FOR I% = 0 TO 8: y(I%) = y1 + YY(I%): x(I%) = x1 + XX(I%): NEXT I%: GOTO 220
200       IF x1 > SIZE THEN y1 = y1 + YMUL: FOR I% = 0 TO 8: y(I%) = y1 + YY(I%): x(I%) = x1 - XX(I%): NEXT I%: GOTO 220
210       FOR I% = 0 TO 8: y(I%) = y1 - YY(I%) + YMUL * (3 + 2*S): x(I%) = x1 - XX(I%): NEXT I%
220       y1 = y1 + YMUL * (1 + S)
230       FOR I% = 0 TO 8
240         xp(I%) = XC + XS * (r00 * x(I%) + r01 * y(I%))
250         yp(I%) = YC + YS * (r10 * x(I%) + r11 * y(I%))
260       NEXT I%
270       LINE (xp(7),yp(7))-(xp(0),yp(0)),15
280       FOR I% = 1 TO 7: LINE -(xp(I%),yp(I%)),15: NEXT I%
290       PAINT (xp(8),yp(8)),X%,15
300     NEXT X%
310   NEXT Y%
320 NEXT A%
330 PRINT "Time taken was ";:PRINT USING "##.####";TIMER-T;:PRINT " seconds"
340 A$ = INPUT$(1)
350 END