Julia set: Difference between revisions

m
Line 465:
=={{header|Julia}}==
 
The following code buildcreates the fractal as a ppm file named julia.ppm. So thereThere is no need of an external library to create the finalthis image ofsince the Juliappm format is straightforward to setgenerate.
 
<lang julia>
function iter(z,c)
n = 0
while (n<256 && normabs2(z)<24) z = z^2+c ; n+=1 end
return n
end
Line 476:
coord(i,j,w,h,a,b) = 2*a*(i-1)/(w-1) - a + im * (2*b*(j-1)/(h-1) - b)
 
palette(n) = string(min(3n,255)," ", min(n,255)," ", 0," ");
 
julia(c) = (w,h,a,b,i,j) -> palette(iter(coord(i,j,w,h,a,b), c))