A teljes Mandelbrot - halmazt kirajzoló Turbo Pascal program
program mandelbrot;
uses crt, graph;
var gd, gm, i, j: integer;
n: byte;
asarok, bsarok, lepes, a, b, x, y, xx, hossz: real;
function szin: byte;
begin
case n of
1..6: szin := 5;
7..12: szin := 13;
13..18: szin := 1;
19..24: szin := 9;
25..30: szin := 3;
31..36: szin := 11;
37..42: szin := 2;
43..48: szin := 10;
49..54: szin := 15;
55..60: szin := 7;
61..66: szin := 14;
67..72: szin := 12;
73..78: szin := 6;
79..84: szin := 4;
85..92: szin := 8;
93..100: szin := 0;
end
end;
begin
gd := detect;
initgraph(gd, gm, 'c:\bp\bgi');
hossz := 2.5;
asarok := -2;
bsarok := -1.25;
lepes := hossz / 440;
a := asarok;
for i := 1 to 440 do
begin
a := a + lepes;
b := bsarok;
for j := 1 to 440 do
begin
b := b + lepes;
x := 0; y := 0; n := 0;
while ( n < 100 ) and ( x * x + y * y < 100 ) do
begin
xx := x * x - y * y + a;
y := 2 * x * y + b;
x := xx;
n := n + 1
end;
putpixel(i+100, 460-j, szin);
end;
end;
readkey
end.