Updated it a bit to fix a couple of annoyances.
Worked out that DBPro is crap with small numbers (even double floats) and so I wouldn't bother trying to write a similar program as you will just tear your hair out when you encounter the problems I found (usually with numbers down below 10 decimal places)
remstart
A Mandelbrot fractal generator in only 20 lines!
After each image drawn, zoom in with left mouse button
variables to play with:
s = pixel size : bigger numbers = blockier image but much quicker to draw
i = maximum iterations : bigger numbers = more detailed image but slower
Only tested on DBPro patched to #2 on an Athlon XP 2000 PC running WinXP Home
V2 fixes:
1. No more blurry image when mouse selecting
2. Fixed some accuracy problems
Problems remaining:
1. After you zoom in about 7 times, everything blocky, this is
because DBPro's maths with very small numbers is very bugged
(take this as a warning if you plan on doing any complicated maths!)
remend
s=1 : i=1000 : sync on : draw sprites first : dim c(153)
x1 as double float : x2 as double float : x3 as double float : x4 as double float : x5 as double float
y1 as double float : y2 as double float : y3 as double float : y4 as double float : y5 as double float
sw=screen width()-1 : sh=screen height()-1 : for f=1 to 153 : read c(f) : next f
x1=-2 : x2=2 : y1=-2 : y2=2 : do
change mouse 1 : for y=0 to sh step s : y3=y1+(y*(y2-y1)/sh) : for x=0 to sw step s : x3=x1+(x*(x2-x1)/sw)
x4=x3 : y4=y3 : t=0 : for m=0 to i : x5=(x4*x4)-(y4*y4)+x3
y5=(x4*y4*2)+y3 : if sqrt((x5*x5)+(y5*y5))>2 : t=(m mod 50)+1 : exit : endif
x4=x5 : y4=y5 : next m : ink rgb(c(t*3+1),c(t*3+2),c(t*3+3)),0 : box x,y,x+s,y+s
next x : sync : next y : get image 1,0,0,sw,sh,1 : sprite 1,0,0,1
set sprite 1,0,0 : change mouse 0 : ink rgb(255,255,255),0 : do : if mouseclick()=1
mx=mousex() : my=mousey() : while mouseclick()=1 : nx=mousex() : ny=mousey()
line mx,my,nx,my : line nx,my,nx,ny : line nx,ny,mx,ny : line mx,ny,mx,my : sync
endwhile : sync : if abs(mx-nx)>10 and abs(my-ny)>10 and nx>mx and ny>my : exit : endif
endif : loop : delete sprite 1 : x3=(x2-x1)/sw : y3=(y2-y1)/sh
x2=x1+(nx*x3) : x1=x1+(mx*x3) : y2=y1+(ny*y3) : y1=y1+(my*y3) : loop
data 0,0,0,175,0,0,193,0,0,209,0,0,223,0,0,235,3,0,244,9,0,250,18,0,253,30,0,253,44,0,250,60,0,244,78,0,235,97,0,223
data 117,0,209,136,0,193,156,0,175,175,0,156,193,0,136,209,0,117,223,0,97,235,0,78,244,0,60,250,2,44,253,10,30,253,24,18
data 250,42,9,244,63,3,246,87,0,223,113,0,209,140,0,193,166,0,175,190,0,156,211,0,136,229,0,117,243,0,97,251,0,78,254,0,60
data 251,0,44,253,0,30,229,3,18,211,9,9,190,19,3,166,30,0,140,44,0,113,60,0,60,78,0,63,97,0,42,117,0,24,136,0,10,156,0,2
I love it when a plan comes together