Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Mandelbrot-set/Zkl/mandelbrot-set.zkl
Normal file
20
Task/Mandelbrot-set/Zkl/mandelbrot-set.zkl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
fcn mandelbrot{ // lord this is slooooow
|
||||
bitmap:=PPM(640,480);
|
||||
foreach y,x in ([0..479],[0..639]){
|
||||
cx:=(x.toFloat()/640 - 0.5)*4.0; //range: -2.0 to +2.0
|
||||
cy:=((y-240).toFloat()/240.0)*1.5; //range: -1.5 to +1.5
|
||||
cnt:=0; zx:=0.0; zy:=0.0;
|
||||
do(1000){
|
||||
if(zx*zx + zy*zy > 2.0){ //z heads toward infinity
|
||||
//set color of pixel to rate it approaches infinity
|
||||
bitmap[x,y]=cnt.shiftLeft(21) + cnt.shiftLeft(10) + cnt*8;
|
||||
break;
|
||||
}
|
||||
temp:=zx*zy;
|
||||
zx=zx*zx - zy*zy + cx; //calculate next iteration of z
|
||||
zy=2.0*temp + cy;
|
||||
cnt+=1;
|
||||
}
|
||||
}
|
||||
bitmap.write(File("foo.ppm","wb"));
|
||||
}();
|
||||
Loading…
Add table
Add a link
Reference in a new issue