June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
44
Task/Mandelbrot-set/Metapost/mandelbrot-set-1.metapost
Normal file
44
Task/Mandelbrot-set/Metapost/mandelbrot-set-1.metapost
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
prologues:=3;
|
||||
outputtemplate:="%j-%c.svg";
|
||||
outputformat:="svg";
|
||||
|
||||
|
||||
def mandelbrot(expr maxX, maxY) =
|
||||
max_iteration := 500;
|
||||
|
||||
color col[];
|
||||
for i := 0 upto max_iteration:
|
||||
t := i / max_iteration;
|
||||
col[i] = (t,t,t);
|
||||
endfor;
|
||||
|
||||
|
||||
for px := 0 upto maxX:
|
||||
for py := 0 upto maxY:
|
||||
xz := px * 3.5 / maxX - 2.5; % (-2.5,1)
|
||||
yz := py * 2 / maxY - 1; % (-1,1)
|
||||
|
||||
x := 0;
|
||||
y := 0;
|
||||
|
||||
iteration := 0;
|
||||
|
||||
forever: exitunless ((x*x + y*y < 4) and (iteration < max_iteration));
|
||||
xtemp := x*x - y*y + xz;
|
||||
y := 2*x*y + yz;
|
||||
x := xtemp;
|
||||
iteration := iteration + 1;
|
||||
endfor;
|
||||
|
||||
draw (px,py) withpen pencircle withcolor col[iteration];
|
||||
|
||||
endfor;
|
||||
endfor;
|
||||
enddef;
|
||||
|
||||
|
||||
beginfig(1);
|
||||
mandelbrot(200, 150);
|
||||
endfig;
|
||||
|
||||
end
|
||||
1
Task/Mandelbrot-set/Metapost/mandelbrot-set-2.metapost
Normal file
1
Task/Mandelbrot-set/Metapost/mandelbrot-set-2.metapost
Normal file
|
|
@ -0,0 +1 @@
|
|||
mpost -numbersystem="double" mandelbrot.mp
|
||||
Loading…
Add table
Add a link
Reference in a new issue