home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #2 / RBBS_vol1_no2.iso / 010z / spiro.bas < prev    next >
BASIC Source File  |  1984-04-27  |  8KB  |  229 lines

  1. 10 '                         PROGRAM SPIROPLOT
  2. 20 '
  3. 30 '                           Randy D. Ralph
  4. 40 '                      33 West Devonshire Street
  5. 50 '                       Winston-Salem, NC 27107
  6. 60 '                           (919) 788-4591
  7. 70 '
  8. 80 ' PLEASE KEEP ME INFORMED OF ANY IMPROVEMENTS YOU MAY MAKE.  THANKS.
  9. 90 '
  10. 100 '  PRAD = Radius of the plotting circle as a decimal fraction.
  11. 110 '         It is converted to pixel units.
  12. 120 '  SRAD = Radius of the static circle in pixel units.
  13. 130 '  PPOINT = Points on the plotter --> converts to radial increment PINC.
  14. 140 '  SPOINT = Points on the stator ---> converts to radial increment SINC.
  15. 150 '  PI = The value of 2 * pi.
  16. 160 '  FRACT = The fraction of PRAD to use when plotting.
  17. 170 '
  18. 180 ' EXPERIMENT WITH NEGATIVE NUMBERS AND FRACTIONS FOR SOME INTERESTING
  19. 190 ' RESULTS.
  20. 200 '
  21. 210 ' ********************** INPUT ROUTINE ***********************
  22. 220 '
  23. 230 CLS
  24. 240 PRINT TAB(30);"PROGRAM SPIROPLOT"
  25. 250 PRINT
  26. 260 PRINT
  27. 270 PRINT TAB(30);"by Randy D. Ralph"
  28. 280 FOR X=1 TO 10:PRINT:NEXT X
  29. 290 PRINT
  30. 300 INPUT "DO YOU NEED INSTRUCTIONS (Y/N)?  ",ANS$
  31. 310 IF ANS$="y" OR ANS$="Y" THEN 1910
  32. 320 KEY (1) ON
  33. 330 ON KEY (1) GOSUB 1710
  34. 340 CLS
  35. 350 PRINT "PRESS F1 TO STOP THE PLOTTING AND BEGIN ANOTHER FIGURE."
  36. 360 PRINT
  37. 370 PRINT "ENTER ZERO TO EXIT THE PROGRAM"
  38. 380 PRINT
  39. 390 PRINT
  40. 400 PRINT "           1 -----> 320 x 200          2 -----> 640 x 200"
  41. 410 PRINT
  42. 420 INPUT "Enter your screen resolution:  ",RES
  43. 430 IF RES=0 THEN 1870
  44. 440 IF RES <1 OR RES >2 THEN 340
  45. 450 ON RES GOTO 460,810
  46. 460 XDIM=319/2:YDIM=199/2
  47. 470 F=1 ' CORRECTION FACTOR FOR WIDTH
  48. 480 C=.5' CORRECTION FACTOR FOR SCREEN SIZE
  49. 490 D=2 ' CORRECTION FACTOR FOR CENTER
  50. 500 PRINT
  51. 510 PRINT "LINE COLOR             PALETTE 0            PALETTE 1"
  52. 520 PRINT
  53. 530 PRINT "  1                      GREEN                CYAN"
  54. 540 PRINT
  55. 550 PRINT "  2                      RED                  BROWN"
  56. 560 PRINT
  57. 570 PRINT "  3                      BROWN                WHITE"
  58. 580 PRINT
  59. 590 INPUT "SELECT PALETTE:  ",PAL
  60. 600 PRINT
  61. 610 INPUT "SELECT LINE COLOR:  ",COL
  62. 620 IF PAL <0 OR PAL >1 THEN 580
  63. 630 IF COL <1 OR COL >3 THEN 580
  64. 640 CLS
  65. 650 PRINT " 0 - BLACK      1 - BLUE      2 - GREEN      3 - CYAN       4 - RED"
  66. 660 PRINT
  67. 670 PRINT
  68. 680 PRINT " 5 - MAGENTA    6 - BROWN     7 - WHITE      8 - GRAY       9 - LT. BLUE"
  69. 690 PRINT
  70. 700 PRINT
  71. 710 PRINT "10 - LG. GRN.  11 - LT. CY.  12 - LT. RED   13 - LT. MAG.  14 - YELLOW"
  72. 720 PRINT
  73. 730 PRINT
  74. 740 PRINT "15 - HIGH INTENSITY WHITE"
  75. 750 PRINT
  76. 760 PRINT
  77. 770 PRINT
  78. 780 INPUT "SELECT BACKGROUND COLOR:  ",BACK
  79. 790 IF BACK<0 OR BACK>15 THEN 750
  80. 800 GOTO 850
  81. 810 XDIM=639/2:YDIM=199/2
  82. 820 F=2 ' CORRECTION FACTOR FOR WIDTH
  83. 830 C=1 ' CORRECTION FACTOR FOR SCREEN SIZE
  84. 840 D=1 ' CORRECTION FACTOR FOR CENTER
  85. 850 CLS
  86. 860 SCREEN 0,0
  87. 870 PRINT
  88. 880 INPUT "Radius of PLOTTER:        ",PRAD
  89. 890 PRINT
  90. 900 INPUT "FRACTION to use:          ",FRACT
  91. 910 PRINT
  92. 920 INPUT "Points on STATOR:         ",SPOINT
  93. 930 PRINT
  94. 940 INPUT "Points on PLOTTER:        ",PPOINT
  95. 950 PRINT
  96. 960 INPUT "OK (Y/N <cr> = Y)?        ",OK$
  97. 970 IF OK$="N" OR OK$="n" THEN 850
  98. 980 '
  99. 990 '************************ CHECK INPUT **************************
  100. 1000 '
  101. 1010 IF PRAD >1 OR PRAD <-1 THEN 1020 ELSE 1080
  102. 1020 PRINT
  103. 1030 PRINT "A PLOTTING RADIUS >1 OR <-1 WILL PRODUCE A FIGURE LARGER THAN THE"
  104. 1040 PRINT "TOTAL AREA AVAILABLE ON SCREEN!"
  105. 1050 PRINT
  106. 1060 INPUT "DO YOU REALLY WANT TO DO THIS (Y/N)?  ",ANS$
  107. 1070 IF ANS$ ="n" OR ANS$="N" THEN 850
  108. 1080 IF PRAD=0 THEN 1090 ELSE 1140
  109. 1090 PRINT
  110. 1100 PRINT "OH, COME ON! A PLOTTER RADIUS OF ZERO JUST MAKES A CIRCLE!"
  111. 1110 PRINT
  112. 1120 INPUT "PRESS ENTER TO CLEAR ERROR",X$
  113. 1130 GOTO 850
  114. 1140 IF SPOINT=PPOINT THEN 1150 ELSE 1210
  115. 1150 PRINT
  116. 1160 PRINT "OH, COME ON! IF THE PLOTTER AND STATOR POINTS ARE EQUAL THAT JUST"
  117. 1170 PRINT "MAKES A CIRCLE!"
  118. 1180 PRINT
  119. 1190 INPUT "PRESS ENTER TO CLEAR ERROR",X$
  120. 1200 GOTO 850
  121. 1210 IF SPOINT = 0 OR PPOINT = 0 THEN 1220 ELSE 1270
  122. 1220 PRINT
  123. 1230 PRINT "OH, COME ON! BOTH CIRCLES HAVE TO HAVE PLOTTING POINTS!"
  124. 1240 PRINT
  125. 1250 INPUT "PRESS ENTER TO CLEAR ERROR",X$
  126. 1260 GOTO 850
  127. 1270 IF FRACT>1 OR FRACT<-1 THEN 1280 ELSE 1340
  128. 1280 PRINT
  129. 1290 PRINT "IF THE FRACTION OF THE PLOTTER RADIUS TO USE IS >1 OR <-1 THE"
  130. 1300 PRINT "FIGURE WILL GO OFF SCREEN!"
  131. 1310 PRINT
  132. 1320 INPUT "DO YOU REALLY WISH TO DO THIS (Y/N)?  ",ANS$
  133. 1330 IF ANS$="n" OR ANS$="N" THEN 850
  134. 1340 IF FRACT=0 THEN 1350 ELSE 1440
  135. 1350 PRINT
  136. 1360 PRINT "OH, COME ON! IF THE FRACTION OF THE PLOTTER RADIUS TO USE IS ZERO"
  137. 1370 PRINT "THAT JUST DRAWS A CIRCLE!"
  138. 1380 PRINT
  139. 1390 INPUT "PRESS ENTER TO CLEAR ERROR",X$
  140. 1400 GOTO 850
  141. 1410 '
  142. 1420 '***************** INITIALIZE AND PLOT ******************
  143. 1430 '
  144. 1440 CLS
  145. 1450 ON RES GOTO 1460,1490
  146. 1460 SCREEN 1,0
  147. 1470 COLOR BACK,PAL
  148. 1480 GOTO 1500
  149. 1490 SCREEN 2,0,0
  150. 1500 N=0
  151. 1510 PI=2*3.141593
  152. 1520 PRAD=YDIM*PRAD*2
  153. 1530 SRAD=(YDIM*2)-PRAD
  154. 1540 PRAD=PRAD*FRACT
  155. 1550 PINC=PI/PPOINT
  156. 1560 SINC=PI/SPOINT
  157. 1570 A=A+SINC
  158. 1580 N=N+1
  159. 1590 B=B+PINC
  160. 1600 X=((SIN(A)*SRAD)+XDIM*D)*C
  161. 1610 Y=((COS(A)*SRAD/F)+YDIM*D)*C
  162. 1620 X1=(COS(B)*PRAD)*C
  163. 1630 Y1=(SIN(B)*PRAD/F)*C
  164. 1640 X=X+X1
  165. 1650 Y=Y+Y1
  166. 1660 IF N=1 THEN 1670 ELSE 1680
  167. 1670 LINE (X,Y)-(X,Y),COL
  168. 1680 LINE -(X,Y),COL
  169. 1690 GOTO 1570
  170. 1700 '
  171. 1710 '******************** RESTORE ALPHA SCREEN AND REDO *******************
  172. 1720 '
  173. 1730 INPUT "PRESS ENTER",X$
  174. 1740 CLS
  175. 1750 SCREEN 0,0
  176. 1760 WIDTH 80
  177. 1770 GOTO 320
  178. 1780 RETURN
  179. 1790 '
  180. 1800 '*********************** EXIT PROGRAM ****************
  181. 1810 '
  182. 1820 SCREEN 0,0
  183. 1830 WIDTH 80
  184. 1840 GOTO 1870
  185. 1850 RETURN
  186. 1860 '*******************************************************
  187. 1870 PRINT
  188. 1880 PRINT "HOPE YOU HAD FUN!"
  189. 1890 PRINT
  190. 1900 GOTO 2280
  191. 1910 '
  192. 1920 '******************** INSTRUCTIONS *****************
  193. 1930 CLS
  194. 1940 PRINT "This program emulates a Spirograph.  It will produce interesting rosettes"
  195. 1950 PRINT "on the screen in either medium resolution color graphics mode or high"
  196. 1960 PRINT "resolution black and white graphics mode.  The parameters you input will"
  197. 1970 PRINT "determine the form of the rosette, background color and line color."
  198. 1980 PRINT
  199. 1990 PRINT "Parameters on screen color and resolution are self-explanatory.  You will"
  200. 2000 PRINT "be asked to enter the radius of the plotting circle.  This is equivalent to"
  201. 2010 PRINT "the disc you place inside the drawing ring and determines its size"
  202. 2020 PRINT "relative to the ring.  It MUST be a positive or negative fraction in the"
  203. 2030 PRINT "range -1 to 1.  If you choose a value of zero a circle will result!  Next"
  204. 2040 PRINT "You will be asked to specify the fraction of the radius of this disc to use"
  205. 2050 PRINT "when plotting.  This is equivalent to selecting the hole in the disc you"
  206. 2060 PRINT "would place your pen in.  The value must be less than 1 and greater than -1."
  207. 2070 PRINT "Values outside this range will produce rosettes larger than the screen and a"
  208. 2080 PRINT "value of zero draws a circle.  You will then be asked to indicate the number"
  209. 2090 PRINT "of points on the plotting circle and the static circle.  Obviously, a number"
  210. 2100 PRINT "of zero is silly.  Experiment with these parameters.  They determine the"
  211. 2110 PRINT "number of tesselations the rosette will have and can produce some very"
  212. 2120 PRINT "peculiar and beautiful results when negative numbers and fractions are used."
  213. 2130 PRINT
  214. 2140 INPUT "PRESS ENTER",X$
  215. 2150 CLS
  216. 2160 PRINT "GOOD LUCK! and have fun.  Please report any improvements to:
  217. 2170 PRINT
  218. 2180 PRINT"                            Randy D. Ralph"
  219. 2190 PRINT "                      33 West Devonshire Street"
  220. 2200 PRINT "                       Winston-Salem, NC 27107"
  221. 2210 PRINT "                           (919) 788-4591"
  222. 2220 PRINT
  223. 2230 PRINT "Thanks!"
  224. 2240 PRINT
  225. 2250 INPUT "PRESS ENTER TO CONTINUE  ",X$
  226. 2260 GOTO 320
  227. 2270 '******************************************************************
  228. 2280 END
  229.