home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / 1987 / 03 / julia.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1987-02-03  |  1.5 KB  |  74 lines

  1. { Zeichnen von Julia-Mengen }
  2.  
  3. PROGRAM Julia;
  4.  
  5. CONST
  6.   xres  = 640;
  7.   yres  = 200;
  8.   ak    = 2;
  9.   xmin  = -2;
  10.   ymin  = -2;
  11.   xmax  = 2;
  12.   ymax  = 2;
  13.   anz   = 4;
  14.   pmin  = 0;   pmax = 0.6;
  15.   qmin  = 0;   qmax = 0.9;
  16.   r_max = 40;
  17.   k_max = 40;
  18.  
  19. VAR
  20.   nx, ny,
  21.   x_null, y_null,
  22.   k, bild_x, bild_y: INTEGER;
  23.   dx, dy,
  24.   x, x_alt, y, q, p: REAL;
  25.  
  26. LABEL exit;
  27.  
  28. {---------------------------------------------------------}
  29.  
  30. PROCEDURE iterat (nx, ny: INTEGER);
  31.  
  32. BEGIN
  33.   k := 0;
  34.   x := xmin + nx * dx;
  35.   y := ymin + ny * dy;
  36.   REPEAT
  37.     x_alt := x;
  38.     x := x * x - y * y + p;
  39.     y := 2 * x_alt * y + q;
  40.     k := k + 1;
  41.   UNTIL (x * x + y * y > r_max) OR (k = k_max);
  42.   IF k = k_max THEN k := 0;
  43.   Plot(x_null + nx, yres - y_null-ny, k mod ak);
  44. END;
  45.  
  46. {---------------------------------------------------------}
  47.  
  48. BEGIN
  49.   ClrScr;
  50.   HiRes;
  51.   HiResColor(15);
  52.   dx := (xmax - xmin) / (xres div anz - 1);
  53.   dy := (ymax - ymin) / (yres div anz - 1);
  54.   FOR bild_x := 0 TO anz-1 DO
  55.   BEGIN
  56.     p := pmin + bild_x * (pmax - pmin) / (anz - 1);
  57.     x_null := bild_x * (xres Div anz);
  58.     FOR bild_y := 0 TO anz-1 DO
  59.     BEGIN
  60.       q := qmin + bild_y * (qmax - qmin) / (anz - 1);
  61.       y_null := bild_y * (yres Div anz);
  62.       FOR nx := 0 TO xres Div anz - 1 DO
  63.       BEGIN
  64.         FOR ny := 0 TO yres Div anz - 1 DO
  65.           iterat(nx,ny);
  66.         IF KeyPressed THEN GOTO exit;
  67.       END;
  68.     END;
  69.   END;
  70.   REPEAT UNTIL KeyPressed;
  71. exit:
  72. END.
  73.  
  74.