Julia set: Difference between revisions

Content added Content deleted
(→‎{{headerJava}}: added Java)
(→‎{{header|Java}}: added zkl)
Line 75: Line 75:
}
}
}</lang>
}</lang>

=={{header|zkl}}==
Uses the PPM class from http://rosettacode.org/wiki/Bitmap/Bresenham%27s_line_algorithm#zkl
{{trans|Java}}
[[File:JuliaSet.zkl.jpg|250px|thumb|right]]
<lang zkl>fcn juliaSet{
w,h,zoom:=800,600, 1;
bitmap:=PPM(w,h,0xFF|FF|FF); // White background

cX,cY:=-0.7, 0.27015;
moveX,moveY:=0.0, 0.0;
maxIter:=255;

foreach x,y in (w,h){
zx:=1.5*(x - w/2)/(0.5*zoom*w) + moveX;
zy:=1.0*(y - h/2)/(0.5*zoom*h) + moveY;
i:=maxIter;
while(zx*zx + zy*zy < 4 and i > 1){
tmp:=zx*zx - zy*zy + cX;
zy,zx=2.0*zx*zy + cY, tmp;
i-=1;
}
// convert byte to RGB (3 bytes), kinda magic to get nice colors
bitmap[x,y]=i.shiftLeft(21) + i.shiftLeft(10) + i*8;
}

bitmap.writeJPGFile("juliaSet.jpg",True);
}();</lang>