home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / graphics / kraska / kraska.doc < prev    next >
Text File  |  1992-01-26  |  17KB  |  386 lines

  1.                                   KRASKA v1.2
  2.                                   ¯¯¯¯¯¯¯¯¯¯¯
  3.                                by Robert Samuel
  4.                                  48 Caie Walk
  5.                                Bury St. Edmunds
  6.                                     Suffolk
  7.                                    IP33 2NZ
  8.  
  9.     KRASKA is my attempt at writing a fractal graphics program. It's not the
  10. first of it's kind, and I'm sure it won't be the last, but it does have one or
  11. two features that make it unique, as far as I know.  The program is freeware -
  12. I don't want any money from anyone for it, but it would be nice to hear
  13. feedback from anybody who uses it. All constructive criticism and suggestions
  14. for improvement are welcome!
  15.     Why KRASKA? Well, 'kraska' is the Russian for 'colour', an appropriate name
  16. for a program of this type. Why Russian? I just happened to have a Russian
  17. dictionary handy when I was trying to think of an original name for it....
  18.     The program was written on a 1040 STFM in GFA Basic v3.5 using Hisoft's
  19. WERCS to construct the resource. It should be able to use all 4096 colours of
  20. the STE's palette, but I'm afraid I haven't been able to test this.
  21.     You should have the following files on this disk:
  22.  
  23.   KRASKA.PRG  The program
  24.   KRASKA.RSC  It's resource file
  25.   KRASKA.DOC  The manual
  26.   KRASKA.GFA  The GFA 3.5 source code
  27.   A selection of pictures in Degas PI* format with corresponding KPR parameter
  28. files
  29.  
  30.     Of these, only the program and it's resource are necessary to use it. Any
  31. others are created as needed by KRASKA.
  32.  
  33.     A full understanding of how the program works and what the different
  34. fractal types actually mean needs an understanding of complex number theory.
  35. This is a subject that has been covered in the ST magazines in the past (e.g.
  36. ST FORMAT 28, November 1991), but is summarised briefly in the Appendix A. An
  37. appreciation of the theory will help you to understand the relationship between
  38. the parameters that KRASKA uses and the final picture produced.
  39.  
  40.                                  Using KRASKA
  41.                                  ¯¯¯¯¯¯¯¯¯¯¯¯
  42.     KRASKA uses a conventional GEM menu bar/dialogue box interface. It will run
  43. from any folder on floppy or hard disk, the only restriction being that the
  44. program and resource file are in the same folder.  It runs in all three
  45. resolutions, and although the prettiest are undoubtedly those produced in low
  46. resolution, the high res mode does have something to offer.
  47.     Double clicking on KRASKA.PRG loads the program, sets the default
  48. parameters, and displays an introductory dialogue box on screen. Clicking
  49. anywhere on the screen or pressing any key then clears the screen and displays
  50. the menu bar with the headings Desk, File, Type, Edit, and Action. The menu
  51. entries are discussed below.
  52.  
  53.                                      Desk
  54.                                      ¯¯¯¯
  55. About
  56.     Displays the introductory dialogue box. Press any key or click mouse to
  57. clear it.
  58.  
  59.                                      File
  60.                                      ¯¯¯¯
  61. Load parameters
  62.     KRASKA stores picture parameters in a file with the extension .KPR.
  63. Selecting this option displays an alert box asking if you wish to replace the
  64. current parameters. If you confirm this, the file selector appears displaying
  65. the .KPR files in the current directory. Selecting one of these loads the
  66. parameters into memory.
  67.  
  68. Save parameters
  69.     Saves the current parameters as a .KPR file
  70.  
  71. Load picture
  72.     Loads and displays a Degas .PI1, .PI2, or .PI3 picture (depending on
  73. resolution). The associated parameter file (which should have the same name,
  74. but extension .KPR) is also loaded. An alert box appears if the parameter file
  75. can't be found.
  76.  
  77. Save picture
  78.     Saves a picture in Degas format along with the parameter file.  For
  79. example, saving a picture as "EXAMPLE1.PI1" would save the parameters in
  80. "EXAMPLE1.KPR".
  81.  
  82. Delete file
  83.     Allows the deletion of any file. An alert box appears asking you to confirm
  84. the deletion after a file has been selected.
  85.  
  86. Quit
  87.     An alert box asks if you are sure you want to leave KRASKA. Click on Yes to
  88. exit the program.
  89.  
  90.                                      Type
  91.                                      ¯¯¯¯
  92.     KRASKA can create pictures using 12 different formulae. The required
  93. fractal type is selected by clicking on the type - a tick by the type shows
  94. which is selected.
  95.     The different types are listed below, and described more fully in Appendix
  96. B.
  97.           1   Mandelbrot
  98.           2   3rd order Mandelbrot
  99.           3   4th Order Mandelbrot
  100.           4   Julia
  101.           5   3rd order Julia
  102.           6   Type 2 Julia
  103.           7   Logarithmic
  104.           8   3rd Order Newton
  105.           9   Sine 1
  106.          10   Sine 2
  107.          11   Sine 3
  108.          12   Sine 4
  109.  
  110.     Types 1 and 4 are the standard Mandelbrot and Julia patterns found in most
  111. fractal graphics programs. Types 2,3,5 and 6 are mathematically related to
  112. these, but give different kinds of pictures. The remaining types use
  113. appreciably different formulae to generate patterns, and it should be noted
  114. that because of the greater mathematical and computational complexity of these
  115. types, they do take a little longer to draw.
  116.  
  117.                                      Edit
  118.                                      ¯¯¯¯
  119.  
  120. Edit parameters
  121.     A dialogue box appears displaying the parameters used by KRASKA to generate
  122. pictures. Those not relevant to the current fractal type (previously selected
  123. from the Type menu) are disabled. The parameters are:
  124.  
  125.          Seed: Real part
  126.                Imaginary part
  127.          Maximum number of iterations
  128.          Iteration radius
  129.          Iteration limit
  130.          Top left     x,y
  131.          Lower right  x,y
  132.              See Appendix B for details.
  133.  
  134.     The last pair of parameters, width and height of draw area, are the size in
  135. pixels of the box within which the picture will be drawn. The default values
  136. will draw a full screen picture. The minimum size allowed is 10 x 10, the
  137. maximum is full screen. Values entered outside these ranges will be adjusted.
  138. Using small values, say 50 x 50, is a useful way of previewing a picture before
  139. starting a full scale drawing.
  140.     Once you've entered the required values for these parameters, click on one
  141. of the exit buttons:
  142.  
  143. Cancel
  144.     Clears the dialogue box and leaves parameters unchanged.
  145.  
  146. Accept
  147.     Clears the dialogue box and replaces the current parameters with those
  148. entered in the box.
  149.  
  150. To KRK
  151.     KRASKA has the facility to store a series of picture parameters in an
  152. autorun file, KRASKA.KRK. Selecting Draw from the Action menu with the autorun
  153. option active causes KRASKA to take its parameters from the autorun file, draw
  154. the picture, save it, and move on to the next set of parameters. This allows
  155. unattended operation of the program, overnight for instance, which is useful
  156. since some of the more complex fractal types can take hours to complete a
  157. picture, particularly in high resolution. Selecting To KRK brings up an alert
  158. box asking whether you want to replace the existing autorun file or to append
  159. the current parameters to it.
  160.  
  161. Set defaults
  162.     Replaces the current parameters with KRASKA's default parameters.
  163.  
  164. Palette 1
  165.     KRASKA has five built-in palettes which are selected by the Palette menu
  166. items - the default on loading KRASKA is Palette 1. If the picture you've just
  167. drawn doesn't look too clear, try changing the palette. It can make quite a
  168. difference!
  169.  
  170.                                     Action
  171.                                     ¯¯¯¯¯¯
  172.  
  173. Draw
  174.     Draws a picture using the current parameters. The process can be
  175. interrupted at any time by pressing any key. An alert boxes then appears asking
  176. if you really want to abort the drawing, or if you'd like to continue.
  177. When the picture is complete, another alert box appears showing the time taken
  178. to draw the picture. Clicking on Ok then leaves the completed picture on
  179. screen.
  180.  
  181. Show pic
  182.     Removes the menu bar allowing you to see the completed picture in its
  183. entirety. Clicking a mouse button restores the menu bar.
  184.  
  185. Zoom
  186.     Using the Zoom function you can close in on any interesting looking portion
  187. of a curve. Position the mouse cursor at the top left corner of the area of
  188. interest, hold the left button down and drag the mouse until the required area
  189. is enclosed. A box is drawn showing the selected area and the coordinates of
  190. the draw area are updated. Selecting Draw will then plot the new picture.
  191.  
  192. Auto run
  193.     One of the nice features of KRASKA is its ability to automatically draw and
  194. save a series of pictures according to a preset series of parameters - see To
  195. KRK. Selecting Autorun activates the Autosave option and reads in the first set
  196. of parameters that has previously been saved in KRASKA.KRK. The program then
  197. draws the picture, saves it and its parameter file to disk, and loads in the
  198. next set of parameters. This process continues until all sets of parameters
  199. have been drawn. If you've chosen to keep a log, then this too will be
  200. updated.
  201.  
  202. Autosave
  203.     Selecting Autosave causes KRASKA to automatically save a completed picture
  204. to disk along with its associated parameter file. See Appendix C for details of
  205. the file naming convention used by the program.
  206.  
  207. Cycle
  208.     Cycle randomly changes the colour palette. This produces some interesting
  209. effects, but is otherwise pretty useless! (See Reset palette)
  210.  
  211. Clear
  212.     Clears the screen.
  213.  
  214. Keep log
  215.     Updates a file called KRASKA.LOG (or creates it if one does not exist) each
  216. time a picture is drawn. The file includes information on the fractal type, its
  217. parameters, the time and date it was saved to disk, and the time it took to
  218. draw. The file is in ASCII format.
  219.  
  220.  
  221.                                   Appendix A
  222.                                   ¯¯¯¯¯¯¯¯¯¯
  223.  
  224. Complex Numbers
  225. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  226.  
  227.     Ordinary numbers such as 1, -1.4, SQR(5), and PI are "real" numbers, and
  228. can be thought of as distances measured along a straight horizontal line from a
  229. zero point, or "origin". Positive numbers lie to the right of the origin,
  230. negative numbers to the left. Suppose we now construct a line perpendicular to
  231. the first line, but still passing through the origin. We can measure distances
  232. along this line from the origin, but now in a vertical direction - what does
  233. this mean?
  234.     Let's go back to the real numbers. Think now of a number as a vector i.e.
  235. as a quantity that has both magnitude (length) and direction (0 or 360 degrees
  236. for positive numbers, 180 or -180 degrees for negative numbers). If we halve
  237. the angles for a positive number we get 0 and 180 degrees - in other words
  238. positive and negative numbers. Now a positive number has two square roots, the
  239. same size but with different signs, so perhaps halving the angle is equivalent
  240. to taking a square root? A negative number conventionally doesn't have a square
  241. root, but if we halve the angles for a negative number we get 90 and -90
  242. degrees, equivalent to moving along the vertical line. So a distance of 1 along
  243. the vertical line is equivalent to SQR(-1). This quantity is denoted by i, and
  244. has the following properties:
  245.  
  246.          1*i = i
  247.          i*i = -1
  248.         -1*i = -i
  249.         -i*i = 1
  250.  
  251. i.e. multiplying by i is equivalent to rotating the vector through 90 degrees
  252. anti-clockwise. Distances along the vertical line therefore represent multiples
  253. of i, and are known as "imaginary" numbers. A distance of 2 units above the
  254. origin would be 2i, 3 units below the origin is -3i.
  255.     Let's now extend the idea a little further. What happens if the point lies
  256. on neither of the lines, but elsewhere on the plane containing the two lines?
  257. This point would require two numbers to define its position on the plane (just
  258. like longitude and latitude). In our case the number would be represented by a
  259. combination of a real and an imaginary number. For example 3-2i would be a
  260. number 3 units to the right of the origin and 2 units below. Such a number is
  261. known as a "complex" number.
  262.     Complex numbers can be added, subtracted, multiplied and divided in the
  263. same way as ordinary numbers can, using the rules defined above for i:
  264.  
  265.     (a+bi)+(c+di)=(a+c)+(b+d)i
  266.  
  267.     (a+bi)-(c+di)=(a-c)+(b-d)i
  268.  
  269.     (a+bi)*(c+di)=a*(c+di)+bi*(c+di)
  270.                  =(a*c)+(a*d*i)+(b*c*i)+(b*d*i*i)
  271.                  =(ac-bd)+(ad+bc)i
  272.  
  273.     (a+bi)   (a+bi)*(c-di)   (ac+bd)+(bc-ad)i
  274.     ------ = ------------- = ----------------
  275.     (c+di)   (c+di)*(c-di)       c^2+d^2
  276.  
  277.     Other mathematical operations, such as sin, log, exp can also be applied to
  278. complex numbers, though the detail is too complicated to go into here.
  279.  
  280.     To go back to the idea of a number as a vector, it can be seen that a real
  281. number is just a special case of a complex number. The general complex number
  282. has a distance from the origin (known as the modulus) and a direction measured
  283. anti-clockwise from the positive real direction (known as the argument). For a
  284. complex number x+yi (denoted by z)
  285.  
  286.     Modulus:  mod(z) = SQR(x^2+y^2)
  287.     Argument: arg(z) = ATN(y/x)
  288.  
  289.     Multiplication and division of complex numbers can now be thought of as
  290. combining the moduli and arguments of the numbers:
  291.  
  292.     mod(z1*z2) = mod(z1) * mod(z2)    mod(z1/z2) = mod(z1) / mod(z2)
  293.     arg(z1*z2) = arg(z1) + arg(z2)    arg(z1/z2) = arg(z1) - arg(z2)
  294.  
  295.    The concept of modulus is important in the theory of fractals (see Appendix
  296. B)
  297.  
  298.  
  299.                                   Appendix B
  300.                                   ¯¯¯¯¯¯¯¯¯¯
  301.  
  302. KRASKA's fractal types
  303. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  304.     In the following explanation of KRASKA's fractal types, the following
  305. variables are used:
  306.  
  307.     w         The complex number equivalent to the coordinates of the point
  308.               being calculated.
  309.     z(N)      The Nth iteration of a calculation sequence.
  310.     R         The iteratiion radius.
  311.     L         The iteration limit.
  312.     Nmax      The maximum number of iterations before the iteration
  313.               terminates.
  314.     c         Seed.
  315.  
  316. Mandelbrot types:
  317.  
  318.     Mandelbrot                    z(N+1)=z(N)^2+w          z(0)=0
  319.     3rd order Mandelbrot          z(N+1)=z(N)^3+w          z(0)=0
  320.     4th order Mandelbrot          z(N+1)=z(N)^4+w          z(0)=0
  321.  
  322.     Iteration continues until N>Nmax or mod(z(N))>R.
  323.  
  324. Julia types:
  325.  
  326.     Julia                         z(N+1)=z(N)^2+c          z(0)=w
  327.     3rd order Julia               z(N+1)=z(N)^3+c          z(0)=w
  328.     Type 2 Julia                  z(N+1)=c*(z(N)^2)+1)     z(0)=w
  329.  
  330.     Iteration continues until N>Nmax or mod(z(N))>R.
  331.  
  332. Logarithmic type:
  333.                                   z(N+1)=z(N)*log(z(N))+c  z(0)=w
  334.  
  335.     Iteration continues until N>Nmax or mod(z(N))>R.
  336.  
  337. Newton type:
  338.  
  339.     Uses the Newton-Raphson iterative method to solve the equation z^3=c.
  340. z(0)=w. Iteration continues until N>Nmax or mod(z(n)-z(n-1))<L.
  341.  
  342. Sine types:
  343.  
  344.     Type 1                        z(N+1)=sin(z(N)+c)       z(0)=w
  345.     Type 2                        z(N+1)=sin(z(N)+c)+w     z(0)=w
  346.     Type 3                        z(N+1)=c*sin(z(N))       z(0)=w
  347.     Type 4                        z(N+1)=z*sin(z(N))+c     z(0)=w
  348.  
  349.     Iteration continues until N>Nmax or mod(z(N))>R.
  350.  
  351.  
  352.                                   Appendix C
  353.                                   ¯¯¯¯¯¯¯¯¯¯
  354. KRASKA's file naming convention
  355. ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
  356.  
  357.     Picture filenames used by KRASKA if the autosave option is selected are of
  358. the following form:
  359.                                  XXXXXRNN.EXT
  360.     The first five charcters of the filename show the fractal type:
  361.      MANDL   Mandelbrot
  362.      MAND3   Third order Mandelbrot
  363.      MAND4   Fourth order Mandelbrot
  364.      JULIA   Julia
  365.      JULI3   Third order Julia
  366.      JULI2   Julia type 2
  367.      LOGAR   Logarithmic
  368.      NEWT3   Third order Newton
  369.      SINE1   Sine type 1
  370.      SINE2   Sine type 2
  371.      SINE3   Sine type 3
  372.      SINE4   Sine type 4
  373.  
  374.     The next character indicates the picture resolution:
  375.      0   Low resolution
  376.      1   Medium resolution
  377.      2   High resolution
  378.  
  379.     The extension shows the file type:
  380.      PI1  Low resolution Degas file
  381.      PI2  Medium resolution Degas file
  382.      PI3  High resolution Degas file
  383.      KPR  KRASKA parameter file
  384.  
  385. 26th January 1992.
  386.