Home » Archimedes archive » Archimedes World » AW-1995-05-Disc1.adf » AWMay95_1 » InTheMag/DrawBasic/RND_Circle

InTheMag/DrawBasic/RND_Circle

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Archimedes World » AW-1995-05-Disc1.adf » AWMay95_1
Filename: InTheMag/DrawBasic/RND_Circle
Read OK:
File size: 01F7 bytes
Load address: 0000
Exec address: 0000
Duplicates

There are 2 duplicate copies of this file in the archive:

File contents
PRINT "You may have to press escape to finish!"
n=20
DIM x(n),y(n),r(n)
�Fill(RND) : �Width(RND(5))
 x(0)=RND(13) : y(0)=RND(15) : r(0)=RND(4)
�Circle(x(0),y(0),r(0))
i=0
REPEAT
 x=RND(13) : y=RND(15) : r=RND(4)
 IF FNDoesNotOverlap(x,y,r,i) THEN
  i+=1 : x(i)=x : y(i)=y : r(i)=r : �Fill(RND) :�Width(RND(10)): �Circle(x,y,r)
  ENDIF
UNTIL i=n
�Quit

DEF  FNDoesNotOverlap(x,y,r,i)
j=0 : ok%=TRUE
REPEAT
 s=SQR((x(j)-x)^2+(y(j)-y)^2)
 IF (r+r(j))>s THEN ok%=FALSE
 j+=1
 UNTIL NOT(ok%) OR j=i+1
 =ok%
 
00000000  50 52 49 4e 54 20 22 59  6f 75 20 6d 61 79 20 68  |PRINT "You may h|
00000010  61 76 65 20 74 6f 20 70  72 65 73 73 20 65 73 63  |ave to press esc|
00000020  61 70 65 20 74 6f 20 66  69 6e 69 73 68 21 22 0a  |ape to finish!".|
00000030  6e 3d 32 30 0a 44 49 4d  20 78 28 6e 29 2c 79 28  |n=20.DIM x(n),y(|
00000040  6e 29 2c 72 28 6e 29 0a  a0 46 69 6c 6c 28 52 4e  |n),r(n)..Fill(RN|
00000050  44 29 20 3a 20 a0 57 69  64 74 68 28 52 4e 44 28  |D) : .Width(RND(|
00000060  35 29 29 0a 20 78 28 30  29 3d 52 4e 44 28 31 33  |5)). x(0)=RND(13|
00000070  29 20 3a 20 79 28 30 29  3d 52 4e 44 28 31 35 29  |) : y(0)=RND(15)|
00000080  20 3a 20 72 28 30 29 3d  52 4e 44 28 34 29 0a a0  | : r(0)=RND(4)..|
00000090  43 69 72 63 6c 65 28 78  28 30 29 2c 79 28 30 29  |Circle(x(0),y(0)|
000000a0  2c 72 28 30 29 29 0a 69  3d 30 0a 52 45 50 45 41  |,r(0)).i=0.REPEA|
000000b0  54 0a 20 78 3d 52 4e 44  28 31 33 29 20 3a 20 79  |T. x=RND(13) : y|
000000c0  3d 52 4e 44 28 31 35 29  20 3a 20 72 3d 52 4e 44  |=RND(15) : r=RND|
000000d0  28 34 29 0a 20 49 46 20  46 4e 44 6f 65 73 4e 6f  |(4). IF FNDoesNo|
000000e0  74 4f 76 65 72 6c 61 70  28 78 2c 79 2c 72 2c 69  |tOverlap(x,y,r,i|
000000f0  29 20 54 48 45 4e 0a 20  20 69 2b 3d 31 20 3a 20  |) THEN.  i+=1 : |
00000100  78 28 69 29 3d 78 20 3a  20 79 28 69 29 3d 79 20  |x(i)=x : y(i)=y |
00000110  3a 20 72 28 69 29 3d 72  20 3a 20 a0 46 69 6c 6c  |: r(i)=r : .Fill|
00000120  28 52 4e 44 29 20 3a a0  57 69 64 74 68 28 52 4e  |(RND) :.Width(RN|
00000130  44 28 31 30 29 29 3a 20  a0 43 69 72 63 6c 65 28  |D(10)): .Circle(|
00000140  78 2c 79 2c 72 29 0a 20  20 45 4e 44 49 46 0a 55  |x,y,r).  ENDIF.U|
00000150  4e 54 49 4c 20 69 3d 6e  0a a0 51 75 69 74 0a 0a  |NTIL i=n..Quit..|
00000160  44 45 46 20 20 46 4e 44  6f 65 73 4e 6f 74 4f 76  |DEF  FNDoesNotOv|
00000170  65 72 6c 61 70 28 78 2c  79 2c 72 2c 69 29 0a 6a  |erlap(x,y,r,i).j|
00000180  3d 30 20 3a 20 6f 6b 25  3d 54 52 55 45 0a 52 45  |=0 : ok%=TRUE.RE|
00000190  50 45 41 54 0a 20 73 3d  53 51 52 28 28 78 28 6a  |PEAT. s=SQR((x(j|
000001a0  29 2d 78 29 5e 32 2b 28  79 28 6a 29 2d 79 29 5e  |)-x)^2+(y(j)-y)^|
000001b0  32 29 0a 20 49 46 20 28  72 2b 72 28 6a 29 29 3e  |2). IF (r+r(j))>|
000001c0  73 20 54 48 45 4e 20 6f  6b 25 3d 46 41 4c 53 45  |s THEN ok%=FALSE|
000001d0  0a 20 6a 2b 3d 31 0a 20  55 4e 54 49 4c 20 4e 4f  |. j+=1. UNTIL NO|
000001e0  54 28 6f 6b 25 29 20 4f  52 20 6a 3d 69 2b 31 0a  |T(ok%) OR j=i+1.|
000001f0  20 3d 6f 6b 25 0a 20                              | =ok%. |
000001f7