10 REM - Rotated Squares Program (45° Rotation)  FLATSQRS.BAS.txt
20 GOSUB 1000 : REM Clear the Screen Routine
30 PI = 3.14159
40 DZOP "C",1 : REM Color mode [Range = 16-23]
50 C = 17 : REM Initial color
60 XC = 128 : YC = 128 : REM Center coordinates
70 FOR SIZE = 20 TO 120 STEP 20 : REM Increasing size for each square
80 GOSUB 2000 : REM Draw rotated square
90 C = C + 1 : IF C > 23 THEN C = 16 : REM Cycle through colors
100 NEXT SIZE
110 GOTO 9999 : REM End of Program

1000 REM Clear the Screen Routine
1010 DZOP "C",16
1020 DZOP "P",0,0
1030 DZOP "R",255,255
1040 RETURN

2000 REM Rotated Square Drawing Routine
2010 DZOP "C",C : REM Set color
2020 FOR VERTEX = 0 TO 3 : REM 4 vertices of the rotated square
2030 X1 = XC + SIZE * COS(PI/4 + PI/2 * VERTEX) : REM 45° rotation added
2040 Y1 = YC + SIZE * SIN(PI/4 + PI/2 * VERTEX) : REM Adjust angles
2050 IF VERTEX = 0 THEN GOSUB 2100 : REM Move to the first vertex
2060 X2 = XC + SIZE * COS(PI/4 + PI/2 * (VERTEX+1))
2070 Y2 = YC + SIZE * SIN(PI/4 + PI/2 * (VERTEX+1))
2080 DZOP "L",X2,Y2 : REM Draw line to the next vertex
2090 NEXT VERTEX
2095 RETURN

2100 REM Move to the first vertex
2110 DZOP "P",X1,Y1
2120 RETURN

9999 REM End of Program
10000 END
