Here is converted javascript code to DBPro, which was obviously a bit more complicated than just converting directly from P5JS. Again, thanks goes to Coding train for ongoing inspiration and other programmers. Will probably add sliders etc for more interactive experience.
If you don't have Matrix1Utils (ian M - thanks for a great plugin), you can replace/convert to use original DBPro code. it's just math at the end of the day.
Play around with iterations and scaling factor of screen co-ords etc.
Rem Project: MandelBrotSet01
Rem Created: Friday, November 29, 2024
remstart
NOTES : RGBA - memblock stores in this order B, G, R, A
remend
#constant width 640 `200 `360 `100 `360 `640
#constant height 480 `200 `360 `100 `360 `480
#constant sizeofDWORD 4
#constant headsize 12
#constant pcol rgb(51,51,51)
#constant npcol rgb(255,0,0)
#constant testcol rgb(51,41,74)
global minval#
minval# = -0.5
global maxval#
maxval# = -0.5
global minSlider
global maxSlider
SetUp()
sync
wait key
end
function SetUp()
sync on : sync rate 0 : sync
backdrop off
`minSlider = createTrackbar(0, 380, 100, 20, 0, 0)
`maxSlider = createTrackbar(300, 380, 100, 20, 0, 0)
loadPixels(width,height,pcol)
`loadPixels(width,height,npcol)
`loadPixels(width,height,testcol)
paste image 1,0,0,0
endfunction
function loadPixels(w ,h ,colrgb as dword )
bmid = reserve free bitmap()
create bitmap bmid,w,h,1
maxiterations = 255
`maxiterations = 1000
lock pixels
for x=0 to w -1
for y = 0 to h -1
`remap x/y screen co-ords for correct pixel placement
a# = 6.0*(x-(width/2.0))/width+0.0
b# = 5.0*(y-(height/2.0))/height+0.0
`a# = 3.2*(x-(width/2.0))/width+0.0
`b# = 3.2*(y-(height/2.0))/height+0.0
ca# = a#
cb# = b#
n=0
z=0
while n<maxiterations
aa# = (a#*a#)-(b#*b#)
bb#= 2 * a# * b#
a#=aa# + ca#
b#=bb# + cb#
if abs(a#+b#) > 16
exit
endif
inc n
endwhile
tbright#=map(n,0,maxiterations,0.0,1.0)
bright#=map(sqrt(tbright#),0.0,1.0,0.0,255.0)
if n = maxiterations
bright# = 0.0
dot x*a#,y*b#, rgb(ceil(bright#),ceil(bright#),ceil(bright#)) //colrgb
else
dot x, y, rgb(ceil(bright#),ceil(bright#),ceil(bright#)) //colrgb
`dot x, y, rgb(rnd(ceil(bright#)),rnd(ceil(bright#)),rnd(ceil(bright#))) //colrgb
endif
next y
next x
unlock pixels
get image 1,0,0,w,h,1
`fourth, remove the old bitmap, we don';t need it anymore
delete bitmap bmid
release reserved bitmap bmid
set current bitmap 0
endfunction
function map(n as float , oldlow as float , oldhigh as float , newlow as float , newhigh as float )
r as float
n=n+0.0 : oldlow=oldlow+0.0 : oldhigh=oldhigh+0.0 : : newlow=newlow+0.0 : newhigh=newhigh+0.0
r = ( ( n - oldlow ) / (oldhigh - oldlow) ) * (newhigh - newlow) + newlow
endfunction r