Home » Archimedes archive » Archimedes World » AW-1995-01-Disc1.adf » Disk1Jan95 » !AWJan95/Goodies/DrawBasic/!DrawBasic/Library/Examples/Chapter/Exer_3/Ex_3/3

!AWJan95/Goodies/DrawBasic/!DrawBasic/Library/Examples/Chapter/Exer_3/Ex_3/3

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-01-Disc1.adf » Disk1Jan95
Filename: !AWJan95/Goodies/DrawBasic/!DrawBasic/Library/Examples/Chapter/Exer_3/Ex_3/3
Read OK:
File size: 01F6 bytes
Load address: 0000
Exec address: 0000
Duplicates

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

File contents
REM > Magic Rose based on circle centre (a,b) with n points (n is a prime number)
      a=5 : b=5 : radius=5
     
     
INPUT "Prime# of points";n
angle=2*PI/n
      
DIM x(n),y(n)
FOR i=0 TO n
 x(i)=a+radius*COS(i*angle) : y(i)=b+radius*SIN(i*angle)
 NEXT
 

 path=�PolyJoin(x(),y())
   
�Quit

END

DEF �PolyJoin(x(),y())
LOCAL n,k,i : n=DIM(x(),1) 
�PathBegin(path)
 �Move(x(0),y(0))
  FOR k=1 TO n DIV 2
   i=0
   REPEAT : i=(k+i) MOD n 
    �Draw(x(i),y(i))
    UNTIL i=0
   NEXT
�PathEnd
=path
00000000  0a 52 45 4d 20 3e 20 4d  61 67 69 63 20 52 6f 73  |.REM > Magic Ros|
00000010  65 20 62 61 73 65 64 20  6f 6e 20 63 69 72 63 6c  |e based on circl|
00000020  65 20 63 65 6e 74 72 65  20 28 61 2c 62 29 20 77  |e centre (a,b) w|
00000030  69 74 68 20 6e 20 70 6f  69 6e 74 73 20 28 6e 20  |ith n points (n |
00000040  69 73 20 61 20 70 72 69  6d 65 20 6e 75 6d 62 65  |is a prime numbe|
00000050  72 29 0a 20 20 20 20 20  20 61 3d 35 20 3a 20 62  |r).      a=5 : b|
00000060  3d 35 20 3a 20 72 61 64  69 75 73 3d 35 0a 20 20  |=5 : radius=5.  |
00000070  20 20 20 0a 20 20 20 20  20 0a 49 4e 50 55 54 20  |   .     .INPUT |
00000080  22 50 72 69 6d 65 23 20  6f 66 20 70 6f 69 6e 74  |"Prime# of point|
00000090  73 22 3b 6e 0a 61 6e 67  6c 65 3d 32 2a 50 49 2f  |s";n.angle=2*PI/|
000000a0  6e 0a 20 20 20 20 20 20  0a 44 49 4d 20 78 28 6e  |n.      .DIM x(n|
000000b0  29 2c 79 28 6e 29 0a 46  4f 52 20 69 3d 30 20 54  |),y(n).FOR i=0 T|
000000c0  4f 20 6e 0a 20 78 28 69  29 3d 61 2b 72 61 64 69  |O n. x(i)=a+radi|
000000d0  75 73 2a 43 4f 53 28 69  2a 61 6e 67 6c 65 29 20  |us*COS(i*angle) |
000000e0  3a 20 79 28 69 29 3d 62  2b 72 61 64 69 75 73 2a  |: y(i)=b+radius*|
000000f0  53 49 4e 28 69 2a 61 6e  67 6c 65 29 0a 20 4e 45  |SIN(i*angle). NE|
00000100  58 54 0a 20 0a 0a 20 70  61 74 68 3d bb 50 6f 6c  |XT. .. path=.Pol|
00000110  79 4a 6f 69 6e 28 78 28  29 2c 79 28 29 29 0a 20  |yJoin(x(),y()). |
00000120  20 20 0a a0 51 75 69 74  0a 0a 45 4e 44 0a 0a 44  |  ..Quit..END..D|
00000130  45 46 20 bb 50 6f 6c 79  4a 6f 69 6e 28 78 28 29  |EF .PolyJoin(x()|
00000140  2c 79 28 29 29 0a 4c 4f  43 41 4c 20 6e 2c 6b 2c  |,y()).LOCAL n,k,|
00000150  69 20 3a 20 6e 3d 44 49  4d 28 78 28 29 2c 31 29  |i : n=DIM(x(),1)|
00000160  20 0a a0 50 61 74 68 42  65 67 69 6e 28 70 61 74  | ..PathBegin(pat|
00000170  68 29 0a 20 a0 4d 6f 76  65 28 78 28 30 29 2c 79  |h). .Move(x(0),y|
00000180  28 30 29 29 0a 20 20 46  4f 52 20 6b 3d 31 20 54  |(0)).  FOR k=1 T|
00000190  4f 20 6e 20 44 49 56 20  32 0a 20 20 20 69 3d 30  |O n DIV 2.   i=0|
000001a0  0a 20 20 20 52 45 50 45  41 54 20 3a 20 69 3d 28  |.   REPEAT : i=(|
000001b0  6b 2b 69 29 20 4d 4f 44  20 6e 20 0a 20 20 20 20  |k+i) MOD n .    |
000001c0  a0 44 72 61 77 28 78 28  69 29 2c 79 28 69 29 29  |.Draw(x(i),y(i))|
000001d0  0a 20 20 20 20 55 4e 54  49 4c 20 69 3d 30 0a 20  |.    UNTIL i=0. |
000001e0  20 20 4e 45 58 54 0a a0  50 61 74 68 45 6e 64 0a  |  NEXT..PathEnd.|
000001f0  3d 70 61 74 68 0a                                 |=path.|
000001f6