home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / MacMETH 3.2.1 / More Examples / Mandelbrot.MOD < prev    next >
Encoding:
Text File  |  1992-12-29  |  6.3 KB  |  67 lines  |  [TEXT/MEDT]

  1. MODULE Mandelbrot; (* HS 29-Jan-90 *)
  2.    
  3. FROM Terminal IMPORT BusyRead;
  4. FROM InOut IMPORT Read, ReadInt, ReadReal, WriteReal,
  5.                   WriteString, WriteLn, Write, Done;
  6. FROM GraphicWindows IMPORT Window, Mode, OpenGraphicWindow, CloseGraphicWindow,
  7.                  Circle, Clear, SetMode, SetPen, MoveTo, Dot, IdentifyPos;
  8. FROM CursorMouse IMPORT GetMouse;
  9. FROM FileSystem IMPORT File, Response, Lookup, Close, WriteChar;
  10. FROM Conversions IMPORT IntToString, LongIntToString;
  11. IMPORT Windows;
  12.  
  13.        To(w,ox,oy);
  14.           Windows.ResetWindow;
  15.     GetPos(ix,iy); (* wait for mouse click *)
  16.     Clear(w);
  17.   END;
  18.  
  19.   OpenGraphicWindow(v,360,40,NrPixels,NrPixels+20,"Julia Set",Clear);
  20.   LOOP      
  21.     WriteString ('give c for julia set'); WriteLn;
  22.     WriteString ('define mouse-point !'); WriteLn;
  23.     GetPos(ix,iy);
  24.     ox := ix; oy := iy;
  25.     ux := rinic + (FLOAT(ix)*sizec / FLOAT(NrPixels));   
  26.     uy := iinic + (FLOAT(iy)*sizec / FLOAT(NrPixels));
  27.           Windows.SetWindow(w);
  28.           ForeColour(black);
  29.           SetPen(w,ox,oy); Dot(w,ox,oy);
  30.           SetPen(w,ox,oy); MoveTo(w, ox+2, oy);
  31.           SetPen(w,ox,oy); MoveTo(w, ox-2, oy);
  32.           SetPen(w,ox,oy); MoveTo(w, ox, oy+2);
  33.           SetPen(w,ox,oy); MoveTo(w, ox, oy-2);
  34.           Windows.ResetWindow;
  35.     GetPos(ix,iy); (* wait for mouse click *)
  36.     Clear(v);
  37.     WriteString ('drawing Julia Set.'); WriteLn;
  38.     lim := 100;
  39.     SetColours(lim);
  40.     Fractal(ux, uy, -2.25, -2.25, 4.5);
  41.           ox := TRUNC( ((ux + 2.25) * FLOAT(NrPixels) / 4.5)  );
  42.           oy := TRUNC( ((uy + 2.25) * FLOAT(NrPixels) / 4.5)  );
  43.           Windows.SetWindow(v);
  44.           ForeColour(zyan);
  45.           SetPen(v,ox+1,oy); MoveTo(v, ox+3, oy);
  46.           SetPen(v,ox-1,oy); MoveTo(v, ox-3, oy);
  47.           SetPen(v,ox,oy+1); MoveTo(v, ox, oy+3);
  48.           SetPen(v,ox,oy-1); MoveTo(v, ox, oy-3);
  49.           ForeColour(black);
  50.           ox := NrPixels DIV 2; oy := ox;
  51.           SetPen(v,ox+1,oy); MoveTo(v, ox+3, oy);
  52.           SetPen(v,ox-1,oy); MoveTo(v, ox-3, oy);
  53.           SetPen(v,ox,oy+1); MoveTo(v, ox, oy+3);
  54.           SetPen(v,ox,oy-1); MoveTo(v, ox, oy-3);
  55.           Windows.ResetWindow;
  56.     WriteString ('continue Y/N:');
  57.     Read(ch); Write(CAP(ch)); WriteLn;
  58.     IF CAP(ch) # "Y" THEN EXIT END;
  59.   END;
  60.  
  61.   CloseGraphicWindow(w);
  62.   CloseGraphicWindow(v);
  63.  
  64.  
  65. END Mandelbrot.
  66.  
  67.