Hi! I've seen your post on bp.org forum but couldn't reply, because I'm banned there. Do yo mean the predefined values of
przesx and
przesy? To be honest I don't remember how I calculated them. I was playing with Mandelbrot Set a lot some time ago and those values are result of it, but I don't remember any details. They are calculated for specific screen resolution (240x160) and won't work with other resolutions. Of course, it's possible to recalculate them, so they would work with other screen resolutions. Here is a version that ask for the width of the screen first:
dim as integer x, y, c, stat, xm, ym, przyc
dim as double a, b, z, a2, b2, x2, y2, x3, y3, przesx, przesy, przelx, przely, pow, maxpow, szer, wys
screen 11
cls
print
input " Width? ", szer
wys = (szer / 3) * 2
screenres szer, wys, 32
windowtitle "Mandelbrot Set"
do
read przesx
przesx = przesx * (szer / 240)
read przesy
przesy = przesy * (wys / 160)
read maxpow
read pow
if pow = 2 then
restore
end if
while (pow < maxpow)
screenlock ()
przelx = 3 / (szer * pow)
przely = 2 / (wys * pow)
for x = 0 to szer - 1
x3 = x - (szer / 2)
for y = 0 to wys - 1
y3 = y - (wys / 2)
a = 0
b = 0
c = 0
x2 = (przelx * (x3 + (przesx * pow))) - 2
y2 = (przely * (y3 + (przesy * pow))) - 1
while (c < 255)
a2 = a * a - b * b
b2 = 2 * a * b
a = a2 + x2
b = b2 + y2
z = a * a + b * b
if z >= 4 then
exit while
end if
c = c + 1
wend
if c = 255 then
pset (x, y), rgb (0, 0, 0)
else
pset (x, y), rgb (255 - c, (c mod 50) * 5, c)
end if
next
next
if asc(inkey) = 255 then
screenunlock()
exit do
end if
pow = pow + pow * 0.04
screenunlock()
sleep 1
wend
loop
end
data 14.17799995, 79.999904, 50 ^ 7, 1, 193.07, 97, 50 ^ 3, 4, 141.098, 11.145, 50 ^ 3, 2
BTW This place is about NaaLaa, EGSL and retro games in other languages, so, if you want to talk about Mandelbrot in FreeBASIC, we probably should move our conversation to pm or email (I don't want to be banned on this forum, too
).