Julia set: Difference between revisions
m
no edit summary
(→{{header|Lua}}: added Lua solution) |
mNo edit summary |
||
Line 171:
</pre>
==={{header|Amazing Hopper}}===
Program made with the Basic-Hopper embedded version, using the tag "#hl {}".
The generated file is binary, and the graph can be made with Matlab's "imshow" function.
<lang basic>
#!/usr/bin/hopper
#include <hopper.h>
main:
hxres = 500 // horizontal resolution
hyres = 500 // vertical resolution
itermax = 100 // maximum iters to do
brk_out = 64 // |z|^2 greater than this is a breakout
magnify = 1 // 10 is standard magnification, but if > 2, resolution should be greater than 500
cr = -0.8 // real part of c in z^2=z^2+c
ci = 0.156 // imaginary part of c in z^2=z^2+c
julia=0,{hxres,hyres}nanarray(julia)
{","}toksep
#hl{ // tag "high-level", Basic language embebed in Hopper
hy=1
while(hy<=hyres)
hx=1
while(hx<=hxres)
y = 4*((((hyres+1-hy-0.5)/hyres)-0.5)/magnify)
x = 4*((((hx-0.5)/hxres)-0.5)/magnify)
zm = 0
iter=1
while(iter<=(itermax-1))
xx = sqrdiff(x,y)+cr //(x*x)-(y*y)+cr
y = (2.0*x*y)+ci
x = xx
zsq = sqradd(x,y) //(x*x)+(y*y)
if (zsq>zm)
zm=zsq
endif
if (zsq>brk_out)
break
endif
iter += 1
wend
if (iter>=itermax)
julia[hy,hx]=1
else
julia[hy,hx]=0
endif
hx+=1
wend
hy+=1
wend
}
toc(t1,t2)
{julia,"julia.dat"}save
exit(0)
</lang>
=={{header|AWK}}==
|