here is mine, it is mouse driven: left, right mouse zoom in out, +/- increase decrease iterations, scrollwheel change zoom window
defint a-z
const sw = 640
const sh = 480
dim shared mx,my,mbl,mbr,mw
dim u as double, v as double
dim uu as double, vv as double
dim xx as double, yy as double
dim x0 as double, y0 as double
dim z as double, zz as double
z = 0.01
zz = 0.1
dim p1 as long
p1 = _newimage(sw, sh, 32)
screen _newimage(sw, sh, 32)
redraw = -1
iter = 100
dim c(100) as long, cc as long
for i=0 to iter-1
if i < iter/6 then
r = 155
g = (i mod (iter/6))*(255/(iter/6))
b = 0
elseif i < 2*iter/6 then
r = 155 - (i mod (iter/6))*(255/(iter/6))
g = 155
b = 0
elseif i < 3*iter/6 then
r = 0
g = 155
b = (i mod (iter/6))*(255/(iter/6))
elseif i < 4*iter/6 then
r = 0
g = 155 - (i mod (iter/6))*(255/(iter/6))
b = 155
elseif i < 5*iter/6 then
r = (i mod (iter/6))*(255/(iter/6))
g = 0
b = 155
else
r = 155
g = 0
b = 155 - (i mod (iter/6))*(255/(iter/6))
end if
c(i) = _rgb(r, g, b)
next
do
mw = 0
getmouse
if redraw then
for y = 0 to sh-1
for x = 0 to sw-1
u = 0
v = 0
xx = (x - sw/2)*z + x0
yy = (y - sh/2)*z + y0
for i = 0 to iter
'''mandelbrot
u = u
v = v
uu = u*u - v*v + xx
vv = 2*u*v + yy
'''
'''burning ship
'u = abs(u)
'v = abs(v)
'uu = u*u - v*v + xx
'vv = 2*u*v + yy
'''
'''tricorn
'u = u
'v = -v
'uu = u*u - v*v + xx
'vv = 2*u*v + yy
'''
'''tetration
'u = u
'v = v
'cexp uu, vv, u, v, u, v
'cexp uu, vv, uu, vv, xx, yy
'''
u = uu
v = vv
if (u*u + v*v) > 4 then exit for
next
if i > iter then
pset(x, y), _rgb(0,0,0)
else
pset(x, y), c(i mod 100)
end if
next
next
'locate 1,1
'print "iter =";iter
_title str$(iter)
_dest p1
_putimage , 0
_dest 0
_putimage , p1
_autodisplay
redraw = 0
end if
if mw < 0 then
zz = zz + 0.01
elseif mw > 0 then
if zz > 0.01 then zz = zz - 0.01
end if
'draw box
if omx <> mx or omy <> my or mw <> 0 then
_putimage , p1
line (mx - (sw*zz/2), my - (sh*zz/2))-step(sw*zz,sh*zz),_rgb(255,255,255),b
_autodisplay
omx = mx
omy = my
end if
if mbl then
do
getMouse
loop while mbl
x0 = x0 + (mx - sw/2)*z
y0 = y0 - (sh/2 - my)*z
z = z*zz
redraw = -1
elseif mbr then
do
getMouse
loop while mbr
x0 = x0 + (mx - sw/2)*z
y0 = y0 - (sh/2 - my)*z
z = z/zz
redraw = -1
end if
k = _keyhit
if k = 43 then
iter = iter + 50
redraw = -1
elseif k = 45 then
if iter > 50 then iter = iter - 50
redraw = -1
end if
loop until k = 27
system
sub getmouse ()
do
mx = _mousex
my = _mousey
mbl = _mousebutton(1)
mbr = _mousebutton(2)
mw = mw + _mousewheel
loop while _mouseinput
end sub
'u + iv = (x + iy) ^ (a + ib)
sub cexp (u as double, v as double, x as double, y as double, a as double, b as double)
dim mag as double, arg as double
dim lnz as double, argz as double
lnz = 0.5*log((x*x + y*y)+0.00001)
argz = _atan2(y, x)
mag = exp(a*lnz - b*argz)
arg = a*argz + b*lnz
u = mag * cos(arg)
v = mag * sin(arg)
end sub