home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 10 / Fresh_Fish_10_2352.bin / new / dev / obero / oberon / demos / mandelbrot.mod (.txt) < prev    next >
Oberon Text  |  1994-11-24  |  3KB  |  78 lines

  1. Syntax10.Scn.Fnt
  2. FoldElems
  3. Syntax10.Scn.Fnt
  4.         VAR z, d: COMPLEX; i: INTEGER;
  5.     BEGIN    i:=0; z:=c; d.re:=z.re*z.re; d.im:=z.im*z.im;
  6.         WHILE    (i <= N) & (d.re+d.im <= 4.0)    DO
  7.             z.im:=2*z.re*z.im+c.im; z.re:=d.re-d.im+c.re;
  8.             d.re:=z.re*z.re; d.im:=z.im*z.im;
  9.             INC(i)
  10.         END;
  11.         RETURN i
  12.     END Iterate;
  13. Syntax10.Scn.Fnt
  14. FoldElems
  15. Syntax10.Scn.Fnt
  16. z: COMPLEX; startre, stepre, stepim: REAL; x, yh, yl, ym: INTEGER; ch: CHAR; M: Viewers.ViewerMsg;
  17. Syntax10i.Scn.Fnt
  18. Syntax10.Scn.Fnt
  19. startre:=-2.0; stepre:=2.0/Display.Width; stepim:=2.0/Display.Height; z.re:=startre; z.im:=1.0;
  20.         yh:=Display.Height; ym:=Display.Height DIV 2; yl:=-1;
  21. Syntax10.Scn.Fnt
  22. Display.ReplConst(Display.black, 0, 0, Display.Width, Display.Height, Display.replace);
  23. Syntax10.Scn.Fnt
  24. (yh > ym)
  25. Syntax10.Scn.Fnt
  26. (Input.Available()=0)
  27. Syntax10.Scn.Fnt
  28. FoldElems
  29. Syntax10.Scn.Fnt
  30.                 IF    ODD(Iterate(z))    THEN
  31.                     Display.Dot(Display.white, x, yh, Display.replace);
  32.                     Display.Dot(Display.white, x, yl, Display.replace)
  33.                 END;
  34.                 INC(x); z.re:=z.re+stepre
  35. Syntax10i.Scn.Fnt
  36. DEC(yh); INC(yl);
  37.             z.im:=z.im-stepim; x:=0; z.re:=startre;
  38.             WHILE    x < Display.Width    DO    
  39. draw dot if odd number of iterations
  40. Syntax10.Scn.Fnt
  41. Input.Read(ch);
  42. Syntax10.Scn.Fnt
  43. M.id:=Viewers.suspend; Viewers.Broadcast(M); M.id:=Viewers.restore; Viewers.Broadcast(M)
  44.     (*Display.Height is always even under MacOberon 3.x *)
  45.         VAR 
  46. some variables
  47.     BEGIN
  48. init variables
  49. clear screen
  50.         WHILE    
  51. not all lines processed
  52. no key pressed
  53. process next line
  54.     END;
  55. wait for key press
  56. refresh screen
  57.     END Draw;
  58. Syntax10i.Scn.Fnt
  59. MODULE Mandelbrot;    (* Michael Franz, 16.1.92 / 25.10.93 *)
  60.     IMPORT
  61.         Display, Input, Viewers;
  62.     CONST
  63.         N=50;
  64.     TYPE
  65.         COMPLEX=RECORD re, im: REAL END;
  66.     PROCEDURE Iterate(c: COMPLEX): INTEGER;
  67.     PROCEDURE Draw*;
  68. click on the triangle to expand the folded text
  69. END Mandelbrot.Draw    <- This is a command that can be executed directly.
  70. This document contains "hypertext folds" that aid in the construction
  71. of programs via the process of stepwise refinement.
  72. You can compile this program without first expanding all of the folded text
  73. by marking this viewer (press Enter on the keypad) and using the command
  74.     XE.Comp *
  75. In order to expand and collaps all of the folds simultaneously, mark this
  76. viewer and execute one of the two commands below:
  77.     FoldElems.Expand    FoldElems.Collapse
  78.