fb:porticula NoPaste
Fractal Calculation 1.4
Uploader: | psygate |
Datum/Zeit: | 11.03.2006 14:52:13 |
option explicit
'Juliamengenu. Mandelbrot Berechnung by psygate
'Copright 2006
'-------------------------------------------------------------------------------
'types:
'-------------------------------------------------------------------------------
'Dimensions:
dim as double m,n,p,q,i,x,y,u,v,z,a,tist,fade
dim shared as string key,path
dim shared as integer steps=1,num,xmax,ymax,cycle,t,pal(256),col1,col2,l,per,bench
dim as integer xm,ym,julmod,button
const its=1000
const mandfact=1
const magnify=120
const switch=0.1
tist=timer+switch
FADE=1
'-------------------------------------------------------------------------------
'Makros:
#Define div2(a) (a SHR 1)
#Define div4(a) (a SHR 4)
'-------------------------------------------------------------------------------
'Declarations:
declare sub julia(x0 as double,y0 as double, julmod as integer)
declare sub mandelbrot()
'-------------------------------------------------------------------------------
'Main:
screenres 1024,768,,,
screeninfo xmax,ymax
screenlock
'for t=0 to 256
' pal(t)=rgb(255,255,255)\256*t
'next t
mandelbrot
screenunlock
do
if fade=1 then
if timer>tist then
screenlock
for l=0 to 255
palette get 1,col1
palette get l+1,col2
palette l,col2
palette 255,col1
next l
screenunlock
tist=timer+switch
end if
end if
getmouse xm,ym,,button
screenlock
if button=1 then julia((xm-div2(xmax))/magnify,(ym-div2(ymax))/magnify,julmod)
key=inkey$
select case key
case "m"
julmod=1:julia((xm-div2(xmax))/magnify,(ym-div2(ymax))/magnify,julmod)
case "n"
julmod=0:julia((xm-div2(xmax))/magnify,(ym-div2(ymax))/magnify,julmod)
case "h"
steps+=1:cls:mandelbrot:julia((xm-div2(xmax))/magnify,(ym-div2(ymax))/magnify,julmod)
case "f"
if steps-1>0 then steps-=1:cls:mandelbrot:julia((xm-div2(xmax))/magnify,(ym-div2(ymax))/magnify,julmod)
case "b"
num+=1:path="fraktal"+str$(num)+".bmp":bsave path,0
case chr(27)
screenunlock:system
case "c"
fade=not fade:tist=timer
case "r"
if tist >0 then tist=tist-0.1
case "s"
tist=tist+0.1
case "z"
bench=not bench
case "j"
julia((xm-div2(xmax))/magnify,(ym-div2(ymax))/magnify,julmod)
case "a"
mandelbrot
end select
key=""
screenunlock
loop
system
'-------------------------------------------------------------------------------
'Subs; Functions:
sub julia(x0 as double,y0 as double,julmod as integer)
dim as double nx,ny,x,y,xn,yn,dx,dy,n,d,xb,yb,mb,l=2,times
dim as integer q,p,col1,col2,steper,lps
times=timer
if julmod=0 then steper=4
if julmod=1 then steper=steps
for nx=0 to xmax-1 step steper
for ny=0 to ymax-1 step steper
x=4/ymax*(nx-xmax\4/2)
y=-4/ymax*(ny-ymax\4/2)
for n=1 to its
' Activate for Benchmarking:
' if times<timer and bench=-1 then times=timer+1:locate 1,1:print " ":locate 1,1:print lps:lps=0
' if times>timer then lps+=1
xn=x*x-y*y+x0*mandfact
yn=2*x*y+y0*mandfact
x=xn
y=yn
if xn*xn+yn*yn>4 then goto blank
next n
blank:
if julmod=0 then pset(3*xmax\4+nx\4,3*y\4+ny\4),n
if julmod=1 then pset(nx,ny),n
next ny
next nx
end sub
sub mandelbrot
dim as double m,n,p,q,i,x,y,u,v,z,a,l,xb,yb,mb,times
dim as integer lps
l=2
for m=1 to xmax step steps
for n=1 to ymax\2 step steps
p=(m-div2(xmax))/magnify
q=-(n-div2(ymax))/magnify
x=0
y=0
for i=1 to its
' Activate for Benchmarking:
' if times<timer and bench=-1 then times=timer+1:locate 1,1:print " ":locate 1,1:print lps:lps=0
' if times>timer then lps+=1
u=x*x-y*y+p*mandfact
v=2*x*y+q*mandfact
if u*u+v*v>4 then goto ender
x=u
y=v
next i
ender:
pset(m,n),i
pset(m,ymax-n),i
next n
next m
end sub