Acorn Computers BBC Micro Model B w/8271 — Acorn BBC Micro Model B w/8271 User Guide Manual PDF

31 POLYGON This program draws polygons (many sided shapes) in random colours. Lines 120 to 180 move to a random place on the screen which will be the centre (origin) of the next shape. Lines 210 to 290 calculate the X and Y coordinates of each ‘corner’ of the polygon and store the values in two ‘arrays’ for future use. In addition the shape is filled with black triangles (lines 260 and 290) that make it appear that the new polygon is in front of the older ones. Lines 310 to 370 draw all the lines that make up the polygon. Lines 50 to 70 set the actual colour of logical colours 1,2 and 3 to red, blue and yellow. You can change these if you wish to use other colours.

10 REM POLYGON 20 REM JOHN A COLL 30 REM VERSION 1 / 16 NOV 81 40 MODE5 50 VDU 19,1,1,0,0,0 60 VDU 19,2,4,0,0,0 70 VDU 19,3,3,0,0,0 80 DIM X(10) 90 DIM Y(10) 100 110 FOR C=1 TO 2500 120 xorigin=RND(1200) 130 yorigin=RND(750) 140 VDU29,xorigin;yorigin; 150 radius=RND(300)+50 160 sides=RND(8)+2 170 MOVE radius,0 180 MOVE 10,10 190 200 GCOL 0,0 210 FOR SIDE=1 TO sides 220 angle=(SIDE-1)*2*PI/sides 230 X(SIDE)=radius*COS(angle) 240 Y(SIDE)=radius*SIN(angle) 250 MOVE0,0 260 PLOT 85,X(SIDE), Y(SIDE) 270 NEXT SIDE 280 MOVE0,0 290 PLOT 85,radius,0 300 310 GCOL 0,RND(3) 320 FOR SIDE=1 TO sides 330 FOR line=SIDE TO sides