home *** CD-ROM | disk | FTP | other *** search
- { Zeichnet Apfelmaenchen = Mandelbrot-Menge }
-
- PROGRAM apfelman;
-
- USES Crt, Graph;
-
- LABEL exit;
-
- CONST
- pmin = -2.25;
- pmax = 0.75;
- qmin = -1.5;
- qmax = 1.5;
- r_max = 50;
- k_max = 50;
-
- VAR
- GraphDriver,
- GraphMode,
- GraphCode : INTEGER;
- xres, yres, ak : WORD;
- np, nq, k : INTEGER;
- dp, dq,
- p, q,
- x, x_alt, y : REAL;
-
- {---------------------------------------------------------}
-
- PROCEDURE iterat (np, nq: INTEGER);
-
- BEGIN
- p := pmin + np * dp;
- q := qmin + nq * dq;
- k := 0;
- x := 0;
- y := 0;
- REPEAT
- x_alt := x;
- x := x * x - y * y + p;
- y := 2 * x_alt * y + q;
- k := k + 1;
- UNTIL (x * x + y * y > r_max) OR (k = k_max);
- IF k = k_max THEN
- k := 0;
- PutPixel(np, yres - nq, k Mod ak);
- END;
-
- {---------------------------------------------------------}
-
- BEGIN
- GraphDriver := Detect;
- InitGraph(GraphDriver,GraphMode,'');
- GraphCode := GraphResult;
- IF GraphCode <> grOk THEN BEGIN
- WriteLn('Grafik-Fehler Nr. ',GraphCode);
- Writeln('Programm abgebrochen...');
- Halt;
- END;
- xres := GetMaxX; yres := GetMaxY; ak := GetMaxColor+1;
- dp := (pmax - pmin) / xres;
- dq := (qmax - qmin) / yres;
- FOR np := 0 TO xres - 1 DO
- BEGIN
- FOR nq := 0 TO yres - 1 DO
- iterat(np, nq);
- IF KeyPressed THEN GOTO exit;
- END;
- REPEAT UNTIL KeyPressed;
- exit:
- CloseGraph;
- END.