01-08-2007, 04:27 AM
Surprise!
Maybe not to some, since an older version has been visible on freebasic.net forums, but I though you migh be interested here too.
Maybe not to some, since an older version has been visible on freebasic.net forums, but I though you migh be interested here too.
Code:
' random/changing IFS fractal generator by red_Marvin/insomninja code is licensed under the GNU GPL
#define fc 6.283185308
declare sub ifs(x0 as single, y0 as single, branchcount as uinteger, l0 as single, a0 as single, lm as single ptr, am as single ptr, maxdepth as integer, depth as uinteger = 0)
randomize timer
dim as uinteger md = 10
dim as uinteger bc = 3
dim as single ptr lm = callocate(len(single)*bc)
dim as single ptr am = callocate(len(single)*bc)
dim as single ptr lma = callocate(len(single)*bc)
dim as single ptr ama = callocate(len(single)*bc)
dim as single a0=rnd*fc
for n as integer = 0 to bc-1
lma[n]=rnd*.2+.8
ama[n]=(rnd-rnd)/100
lm[n]=rnd
am[n]=rnd*fc
next
screenres 1024,768,32,1,&H41
setmouse,,0
do
screenlock
cls
ifs(512, 384, bc, 100, a0, lm, am, md)
screenunlock
for n as integer = 0 to bc-1
lma[n]*=rnd/500+.999
if lma[n]>1.01 then lma[n]=1.01
if lma[n]<.99 then lma[n]=.99
lm[n]*=lma[n]
if lm[n]>.9 then lm[n]=.9 : lma[n]=1
if lm[n]<.5 then lm[n]=.5 : lma[n]=1
ama[n]+=(rnd-rnd)/1000
if ama[n]>.01 then ama[n]=.01
if ama[n]<-.01 then ama[n]=-.01
am[n]+=ama[n]
if am[n]>fc then am[n]-=fc
if am[n]<0 then am[n]+=fc
next
sleep 15
loop while inkey=""
deallocate lm
deallocate am
deallocate lma
deallocate ama
sub ifs(x0 as single, y0 as single, branchcount as uinteger, l0 as single, a0 as single, lm as single ptr, am as single ptr, maxdepth as integer, depth as uinteger = 0)
if depth < maxdepth then
dim as single l1, a1, x1, y1
for n as uinteger = 0 to branchcount-1
l1=l0*lm[n]
a1=a0+am[n]
x1=x0+l1*cos(a1)
y1=y0+l1*sin(a1)
line(x0, y0)-(x1, y1), rgba(255,255,255,64-depth*64\maxdepth)
ifs(x1, y1, branchcount, l1, a1, lm, am, maxdepth, depth+1)
next
end if
end sub
/post]