Home » Archimedes archive » Archimedes World » AW-1995-02-Disc1.adf » Disk1Feb95 » !AWFeb95/Goodies/DrawBasic/!DrawBasic/Library/RND_Circle

!AWFeb95/Goodies/DrawBasic/!DrawBasic/Library/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-02-Disc1.adf » Disk1Feb95
Filename: !AWFeb95/Goodies/DrawBasic/!DrawBasic/Library/RND_Circle
Read OK:
File size: 01C8 bytes
Load address: 0000
Exec address: 0000
Duplicates

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

File contents
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  0a 6e 3d 32 30 0a 44 49  4d 20 78 28 6e 29 2c 79  |.n=20.DIM x(n),y|
00000010  28 6e 29 2c 72 28 6e 29  0a a0 46 69 6c 6c 28 52  |(n),r(n)..Fill(R|
00000020  4e 44 29 20 3a 20 a0 57  69 64 74 68 28 52 4e 44  |ND) : .Width(RND|
00000030  28 35 29 29 0a 20 78 28  30 29 3d 52 4e 44 28 31  |(5)). x(0)=RND(1|
00000040  33 29 20 3a 20 79 28 30  29 3d 52 4e 44 28 31 35  |3) : y(0)=RND(15|
00000050  29 20 3a 20 72 28 30 29  3d 52 4e 44 28 34 29 0a  |) : r(0)=RND(4).|
00000060  a0 43 69 72 63 6c 65 28  78 28 30 29 2c 79 28 30  |.Circle(x(0),y(0|
00000070  29 2c 72 28 30 29 29 0a  69 3d 30 0a 52 45 50 45  |),r(0)).i=0.REPE|
00000080  41 54 0a 20 78 3d 52 4e  44 28 31 33 29 20 3a 20  |AT. x=RND(13) : |
00000090  79 3d 52 4e 44 28 31 35  29 20 3a 20 72 3d 52 4e  |y=RND(15) : r=RN|
000000a0  44 28 34 29 0a 20 49 46  20 46 4e 44 6f 65 73 4e  |D(4). IF FNDoesN|
000000b0  6f 74 4f 76 65 72 6c 61  70 28 78 2c 79 2c 72 2c  |otOverlap(x,y,r,|
000000c0  69 29 20 54 48 45 4e 0a  20 20 69 2b 3d 31 20 3a  |i) THEN.  i+=1 :|
000000d0  20 78 28 69 29 3d 78 20  3a 20 79 28 69 29 3d 79  | x(i)=x : y(i)=y|
000000e0  20 3a 20 72 28 69 29 3d  72 20 3a 20 a0 46 69 6c  | : r(i)=r : .Fil|
000000f0  6c 28 52 4e 44 29 20 3a  a0 57 69 64 74 68 28 52  |l(RND) :.Width(R|
00000100  4e 44 28 31 30 29 29 3a  20 a0 43 69 72 63 6c 65  |ND(10)): .Circle|
00000110  28 78 2c 79 2c 72 29 0a  20 20 45 4e 44 49 46 0a  |(x,y,r).  ENDIF.|
00000120  55 4e 54 49 4c 20 69 3d  6e 0a a0 51 75 69 74 0a  |UNTIL i=n..Quit.|
00000130  0a 44 45 46 20 20 46 4e  44 6f 65 73 4e 6f 74 4f  |.DEF  FNDoesNotO|
00000140  76 65 72 6c 61 70 28 78  2c 79 2c 72 2c 69 29 0a  |verlap(x,y,r,i).|
00000150  6a 3d 30 20 3a 20 6f 6b  25 3d 54 52 55 45 0a 52  |j=0 : ok%=TRUE.R|
00000160  45 50 45 41 54 0a 20 73  3d 53 51 52 28 28 78 28  |EPEAT. s=SQR((x(|
00000170  6a 29 2d 78 29 5e 32 2b  28 79 28 6a 29 2d 79 29  |j)-x)^2+(y(j)-y)|
00000180  5e 32 29 0a 20 49 46 20  28 72 2b 72 28 6a 29 29  |^2). IF (r+r(j))|
00000190  3e 73 20 54 48 45 4e 20  6f 6b 25 3d 46 41 4c 53  |>s THEN ok%=FALS|
000001a0  45 0a 20 6a 2b 3d 31 0a  20 55 4e 54 49 4c 20 4e  |E. j+=1. UNTIL N|
000001b0  4f 54 28 6f 6b 25 29 20  4f 52 20 6a 3d 69 2b 31  |OT(ok%) OR j=i+1|
000001c0  0a 20 3d 6f 6b 25 0a 20                           |. =ok%. |
000001c8