Mandelbrot Set - ASCII Rendering
// Mandelbrot Set - ASCII Rendering
const cWidth = 60;
const cHeight = 30;
const cChars = ' .:-=+*#%@';
for var y := 0 to cHeight - 1 do begin
var im := -1.2 + (y * 2.4 / cHeight);
var line := '';
for var x := 0 to cWidth - 1 do begin
var re := -2.0 + (x * 3.0 / cWidth);
var z_re := re;
var z_im := im;
var iter := 0;
var inside := True;
while (z_re*z_re + z_im*z_im <= 4.0) and (iter < 30) do begin
var next_re := z_re*z_re - z_im*z_im + re;
z_im := 2*z_re*z_im + im;
z_re := next_re;
Inc(iter);
end;
if iter >= 30 then
line += ' '
else
line += cChars[(iter mod Length(cChars)) + 1];
end;
PrintLn(line);
end;
..........:::::::::::::::::::::::::.................
.......:::::::::::::::::----=#==----::::.............
......::::::::::::::::------=+*%*++----::::...........
.....::::::::::::::::------===+#@%@*=-----::::.........
...::::::::::::::::-------===*. @ ##+==----:::::.......
..::::::::::::::::-------==++*#- ##+====--::::::.....
..:::::::::::::::------==+****#@+ =%#*++++=-::::::....
.::::::::::::::-----===+*.:+ : %#%=*=-::::::...
.:::::::::::::---=====+++#@ +-==-::::::..
:::::::::::--========++* = @*+=-:::::::.
.:::::::---==*.*********# @ *%%=--::::::.
::::-----===+*-# @.=@@%%@# @+--:::::::
::------====**%@ =.- =@=---::::::
------====+#%@* :+=---::::::
-==-=+++**% %* +*+=---::::::
.#*+=---::::::
-==-=+++**% %* +*+=---::::::
------====+#%@* :+=---::::::
::------====**%@ =.- =@=---::::::
::::-----===+*-# @.=@@%%@# @+--:::::::
.:::::::---==*.*********# @ *%%=--::::::.
:::::::::::--========++* = @*+=-:::::::.
.:::::::::::::---=====+++#@ +-==-::::::..
.::::::::::::::-----===+*.:+ : %#%=*=-::::::...
..:::::::::::::::------==+****#@+ =%#*++++=-::::::....
..::::::::::::::::-------==++*#- ##+====--::::::.....
...::::::::::::::::-------===*. @ ##+==----:::::.......
.....::::::::::::::::------===+#@%@*=-----::::.........
......::::::::::::::::------=+*%*++----::::...........
.......:::::::::::::::::----=#==----::::.............