madelbort zoom movie maker try

General FreeBASIC programming questions.
bluatigro
Posts: 597
Joined: Apr 25, 2012 10:35
Location: netherlands

madelbort zoom movie maker try

error :
if i go deep in the fractel
my black does not lessen if i choise '='

Code: Select all

type complex
dim i as double
dim r as double
declare constructor()
declare constructor( a as double , bj as double )
declare sub fill( a as double , bj as double )
declare function lenght() as double
end type
constructor complex( )
this.r = 0
this.i = 0
end constructor
constructor complex( a as double , bj as double )
this.r = a
this.i = bj
end constructor
sub complex.fill( a as double , bj as double )
this.r = a
this.i = bj
end sub
function complex.lenght() as double
return sqr( this.i ^ 2 + this.r ^ 2 )
end function
operator + ( a as complex , b as complex ) as complex
return type( a.r + b.r , a.i + b.i )
end operator
operator * ( a as complex , b as complex ) as complex
return type( a.r * b.r - a.i * b.i , a.r * b.i + a.i * b.r )
end operator

const as double pi = atn( 1 ) * 4
declare function rad( deg as double ) as double
declare function rainbow( deg as double ) as integer

dim as double x , y
dim as integer tel , dept = 16
dim as complex nu , punt
dim as string in

dim as double mx = 0 , my = 0 , diam = 2
screen 20 , 32
while in <> "q" and in <> "t"
cls
for x = 0 to 1024
for y = 0 to 768
tel = 0
nu.fill ( x - 1024 / 2 ) / 1024 * diam - mx , ( y - 768 / 2 ) / 768 * diam - my
punt.fill ( x - 1024 / 2 ) / 1024 * diam - mx , ( y - 768 / 2 ) / 768 * diam - my
while nu.lenght < 50 and tel < dept
tel += 1
nu = nu * nu + punt
wend
if tel < 50 then
pset( x , y ) , rainbow( tel * 36 / 5 )
end if
next y
next x
print mx , my , log( diam ) / log( 10 ) , dept
input "[ 0 ... 9 or q or t ] = " ; in
select case in
case "0"
diam *= 2
case "1"
mx += diam / 2
my -= diam / 2
case "2"
my -= diam / 2
case "3"
mx -= diam / 2
my -= diam / 2
case "4"
mx += diam / 2
case "5"
diam /= 2
case "6"
mx -= diam / 2
case "7"
mx += diam / 2
my += diam / 2
case "8"
my += diam / 2
case "9"
mx -= diam / 2
my += diam / 2
case "="
dept *= 2
case "-"
dept /= 2
case else
end select
wend
if in = "t" then
print "[ end test ]"
sleep
end
end if
input "path + filename [ -.bmp ] = " ; in
diam = 2
dim as integer frame
while diam > 10e-14
cls
for x = 0 to 1024
for y = 0 to 768
tel = 0
nu.fill ( x - 1024 / 2 ) / 1024 * diam - mx , ( y - 768 / 2 ) / 768 * diam - my
punt.fill ( x - 1024 / 2 ) / 1024 * diam - mx , ( y - 768 / 2 ) / 768 * diam - my
while nu.lenght < 50 and tel < dept
tel += 1
nu = nu * nu + punt
wend
if tel < 50 then
pset( x , y ) , rainbow( tel * 36 / 5 )
end if
next y
next x
bsave in + right( "000000" + str( frame ) , 5 ) + ".bmp" , 0
diam /= 10 ^ 0.1
frame += 1
wend
print "[ game over ]"
end
function rad( deg as double ) as double
return  deg * pi / 180
end function
function rainbow( deg as double ) as integer
return rgb( sin( rad( deg ) ) * 127 + 128 _
, sin( rad( deg + 120 ) ) * 127 + 128 _
, sin( rad( deg - 120 ) ) * 127 + 128 )
end function

jj2007
Posts: 1242
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: madelbort zoom movie maker try

With the q option, it created 80+ fat bmp files until I could stop it with Ctrl C. Otherwise it works fine.