RosettaCodeData/Task/Julia-set/Amazing-Hopper/julia-set-1.hopper

65 lines
1.4 KiB
Plaintext

#!/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)