defdbl a-z
dim shared pi as double
pi = 4*atn(1)
sw = 800
sh = 600
screen _newimage(sw, sh, 32)
zoom = 100
a = 0.5
k = 0.09
sx = 2
sy = 1
tx = a*exp(k*16)*cos(16) + sx
ty = a*exp(k*16)*sin(16) + sy
x = a*exp(k*0)*cos(0) + sx - tx
y = a*exp(k*0)*sin(0) + sy - ty
r = sqr(x*x + y*y)
arg = _atan2(y, x)
for tt = r to 0 step -1
xl = tt*cos(arg)
yl = tt*sin(arg)
for yy=0 to sh
for xx=0 to sw
u = (xx - sw/2)/zoom
v = (sh/2 - yy)/zoom
cdiv uu, vv, u - xl, v - yl, u + xl, v + yl
clog uu, vv, uu, vv
mm = sqr(uu*uu + vv*vv)
aa = (pi + _atan2(vv, uu))/(2*pi)
pset (xx, yy), hrgb(aa, mm)
next
next
sleep
next
dim pp(5)
pp(5) = 0
pp(4) = 7
pp(3) = 10
pp(2) = 12
pp(1) = 15
pp(0) = 15.9
for ttt= 0 to 5
tt = pp(ttt)
for yy=0 to sh
for xx=0 to sw
u = (xx - sw/2)/zoom
v = (sh/2 - yy)/zoom
uu = 0
vv = 0
for t=tt to 16 step 0.1
x = a*exp(k*t)*cos(t) + sx - tx
y = a*exp(k*t)*sin(t) + sy - ty
cdiv p, q, 1, 0, x - u, y - v
dx = a*exp(k*t)*(k*cos(t) - sin(t))
dy = a*exp(k*t)*(k*sin(t) + cos(t))
cmul p, q, p, q, dx, dy
uu = uu + 0.1*p
vv = vv + 0.1*q
next
for t=16 - 0.1 to tt step -0.1
x =-a*exp(k*t)*cos(t) - sx + tx
y =-a*exp(k*t)*sin(t) - sy + ty
cdiv p, q, 1, 0, x - u, y - v
dx = a*exp(k*t)*(k*cos(t) - sin(t))
dy = a*exp(k*t)*(k*sin(t) + cos(t))
cmul p, q, p, q, dx, dy
uu = uu + 0.1*p
vv = vv + 0.1*q
next
cmul uu, vv, uu, vv, 0, -1/(2*pi)
mm = sqr(uu*uu + vv*vv)
aa = (pi + _atan2(vv, uu))/(2*pi)
pset (xx, yy), hrgb(aa, mm)
next
next
sleep
next
sleep
system
function hrgb&(h, m)
r = 0.5 - 0.5*sin(2*pi*h - pi/2)
g = (0.5 + 0.5*sin(2*pi*h*1.5 - pi/2)) * -(h < 0.66)
b = (0.5 + 0.5*sin(2*pi*h*1.5 + pi/2)) * -(h > 0.33)
n = 128
mm = m*10000 mod 500
p = abs((h*n) - int(h*n))
rr = 200*r - 0.15*mm - 35*p
gg = 200*g - 0.15*mm - 35*p
bb = 200*b - 0.15*mm - 35*p
if rr < 0 then rr = 0
if gg < 0 then gg = 0
if bb < 0 then bb = 0
hrgb& = _rgb(rr, gg, bb)
end function
function cosh#(x as double)
cosh# = 0.5*(exp(x) + exp(-x))
end function
function sinh#(x as double)
sinh# = 0.5*(exp(x) - exp(-x))
end function
'u + iv = (x + iy)^(a + ib)
sub cexp(u, v, xx, yy, aa, bb)
x = xx
y = yy
a = aa
b = bb
lnz = x*x + y*y
if lnz = 0 then
u = 0
v = 0
else
lnz = 0.5*log(lnz)
argz = atan2(y, x)
mag = exp(a*lnz - b*argz)
ang = a*argz + b*lnz
u = mag*cos(ang)
v = mag*sin(ang)
end if
end sub
'u + iv = (x + iy)*(a + ib)
sub cmul(u, v, xx, yy, aa, bb)
x = xx
y = yy
a = aa
b = bb
u = x*a - y*b
v = x*b + y*a
end sub
'u + iv = (x + iy)/(a + ib)
sub cdiv(u, v, xx, yy, aa, bb)
x = xx
y = yy
a = aa
b = bb
d = a*a + b*b
u = (x*a + y*b)/d
v = (y*a - x*b)/d
end sub
sub clog(u, v, xx, yy)
x = xx
y = yy
lnz = x*x + y*y
if lnz = 0 then
u = 0
v = 0
else
u = 0.5*log(lnz)
v = _atan2(y, x)
end if
end sub