Lorenz system (
https://en.wikipedia.org/wiki/Lorenz_system ) flattened out to color domain. Each pixel (x,y) becomes a particle (x,y,z) with random z and we colour it based on how long it takes to get to the center of the 'butterfly' using a poor Euler's method. This image can be zoomed and explored
defdbl 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 = 1
zz = 0.1
dim p1 as long
p1 = _newimage(sw, sh, 32)
screen _newimage(sw, sh, 32)
redraw = -1
iter = 500
dim c(100) as long, cc as long
for i=0 to 100
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
ppp=28
sss=10
bbb=8/3
zzz=0.456
hh=0.01
do
mw = 0
getmouse
if redraw then
for yy = 0 to sh-1
for xx = 0 to sw-1
u = 0
v = 0
x = (xx - sw/2)*z + x0
y = (yy - sh/2)*z + y0
z2 = zzz
for i = 0 to iter
x = x + hh*sss*(y - x)
y = y + hh*(x*(ppp - z2) - y)
z2=z2 + hh*(x*y - bbb*z2)
if (x*x + y*y) < 2 then exit for
next
if i > iter then
pset(xx, yy), _rgb(0,0,0)
else
pset(xx, yy), 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
iter = iter + 50
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