What am I missing??

TB 6.007
Win 7 pro
AMD FX8350
ASUS 990FX

below is a program that displays the Mandelbrot set and allows you to recenter, zoom in and zoom out... I have not put in any niceties like instructions and I do have several "print" statements scattered around to print out some key values at different points for debugging.

My problem is this: after zooming in a few times, you can continue to zoom-in and it will dutifully find the new center, edges and so on, but will not actually draw the picture.

The problem appears to happen in the "drawit" subroutine. The logical window uses the coordinates of the part of the mandelbrot set we are currently observing. So, when you zoom in, the numbers can get small. For example, the leftmost x coordinate once when it stopped drawing was -0.15868566 and the rightmost x coordinate was -0.043158189. Since the number of pixels across the window was about 1900, that meant that in figuring out the status of each pixel, I was incrementing the x coordinate by 0.000060328185 each time. But the program didn't actually draw the picture. it appeared to skip straight past the nested for next loops that were supposed to step it through each x and y coordinate across the screen.

At first I thought perhaps Truebasic did not allow such small step increments and it just bypassed them. So I wrote a short program using "for x=-0.15868566 to -0.043158189 step 0,000060328185" and the program worked just fine counting through each iteration... So why is it not going through them in the program below???

Instructions if you want to test: After the opening screan is fully drawn, select "zoom in" from the menu and then position your mouse pointer where you want the center of the zoom to be and press the left mouse button. After that draws, repeat another 3 or 3 times and you will eventually see it start skipping past the drawing. It is still running, because you can use the menu to exit the program... but it is no longer making a picture.

I've been pulling my hair out on this one. Any help is appreciated.

LIBRARY "C:\Program Files (x86)\TrueBASIC SILVER v6\TBLIBS\TrueCtrl.trc"
DIM menu$ (1, 0:5) ! 1 menu and 4 items (title plus up to 4 choices)
MAT READ menu$
DATA Menu, Zoom In, Zoom Out,Re-center,Re-start,Quit
CALL TC_Init ! Initialize True Controls
CALL TC_Win_Create (1, "BORDER FULL",0,1,0,1)
CALL TC_Win_SetTitle (1, "Grace's Mandelbrot Program")
CALL TC_Menu_Set (1, menu$) ! Set the menu
CALL TC_Show (1)
OPEN #1: SCREEN 0,1,0,1
ASK PIXELS hpix,vpix
ASK MAX COLOR maxcolor
CALL assigncolors (maxcolor)
IF colornum<300 and colornum>100 then
LET maxits=colornum
ELSE
LET maxits=300
END IF
LET event$="MENU"
LET choice=4
LET curlocx=0
LET curlocy=0
DO While not(choice=5)
SET COLOR "BLACK/WHITE"
IF event$="MENU" then
CALL TC_Sensitize (1,0)
LET event$=""
IF choice=1 then
SET COLOR "BLACK/WHITE"
PRINT "1"
CALL TC_Sensitize (1,1)
DO while not(event$="SINGLE")
CALL TC_Event (0, event$, window, curlocx,curlocy)
LOOP
SET COLOR "BLACK/WHITE"
PRINT "1", window, curlocx, curlocy
CALL TC_Sensitize (1,0)
CALL initscreen(minx,maxx,miny,maxy,hpix,vpix,curlocx,curlocy,choice)
SET COLOR "BLACK/WHITE"
PRINT "returned from initscreen", window, curlocx, curlocy,minx, maxx,miny,maxy
SET WINDOW minx,maxx,miny,maxy
CALL drawit (minx,maxx,miny,maxy,hpix,vpix,maxits,maxcolor)
LET choice=0
END IF
IF choice=2 then
DO while not(event$="SINGLE")
CALL TC_Event (0, event$, window, curlocx,curlocy)
LOOP
SET COLOR "BLACK/WHITE"
PRINT "2", window, curlocx, curlocy
REM CALL TC_Sensitize (1,0)
CALL initscreen(minx,maxx,miny,maxy,hpix,vpix,curlocx,curlocy,choice)
SET WINDOW minx,maxx,miny,maxy
CALL drawit(minx,maxx,miny,maxy,hpix,vpix,maxits,maxcolor)
LET choice=0
END IF
IF choice=3 then
PRINT "3"
CALL TC_Sensitize (1,1)
DO while not(event$="SINGLE")
CALL TC_Event (0, event$, window,curlocx,curlocy)
LOOP
SET COLOR "BLACK/WHITE"
PRINT "3", window, curlocx, curlcoy
CALL TC_Sensitize (1,0)
CALL initscreen(minx,maxx,miny,maxy,hpix,vpix,curlocx,curlocy,choice)
SET WINDOW minx,maxx,miny,maxy
CALL drawit (minx,maxx,miny,maxy,hpix,vpix,maxits,maxcolor)
LET choice=0
END IF
IF choice=4 then
CALL initscreen(minx,maxx,miny,maxy,hpix,vpix,curlocx,curlocy,choice)
SET WINDOW minx,maxx,miny,maxy
CALL drawit (minx,maxx,miny,maxy,hpix,vpix,maxits,maxcolor)
LET choice=0
END IF
END IF
CALL TC_Sensitize (1,1)
CALL TC_Event (0, event$, window, mennum,choice)
LOOP
CALL TC_CLEANUP
END
SUB MANDCALC(x,y,maxits,its)
LET its=1
LET a=x
LET b=y
LET nx=0
LET ny=0
DO while (4>a^2+b^2)and(itsvpix then
LET miny=-2
LET maxy=2
LET minx=-((hpix/vpix)*2)
LET maxx=(hpix/vpix)*2
END IF
IF hpixmaxits then
IF its=1 then
SET COLOR its
ELSE IF its=maxits then
SET COLOR maxcolor
ELSE
SET COLOR int(its*(maxcolor/maxits))
END IF
ELSE IF maxcolor0 then LET xwidth=abs(minx)+maxx
IF minx>0 and maxx>0 then LET xwidth=maxx-minx
IF miny<0 and maxy<0 then LET ywidth=miny-maxy
IF miny<0 and maxy>0 then LET ywidth=abs(miny)+maxy
IF miny>0 and maxy>0 then LET ywidth=maxy-miny
END SUB
SUB recenterzoomin (minx,maxx,miny,maxy,curlocx,curlocy)
CALL flsw(minx,maxx,miny,maxy,xwidth,ywidth)
LET xrange=xwidth/8
LET yrange=ywidth/8
LET minx=curlocx-xrange
LET maxx=curlocx+xrange
LET miny=curlocy-yrange
LET maxy=curlocy+yrange
SET COLOR "BLACK/WHITE"
PRINT "zoomin",minx,maxx,miny,maxy
END SUB
SUB recenterzoomout (minx,maxx,miny,maxy,curlocx,curlocy)
CALL flsw(minx,maxx,miny,maxy,xwidth,ywidth)
LET xrange=xwidth
LET yrange=ywidth
LET minx=curlocx-xrange
LET maxx=curlocx+xrange
LET miny=curlocy-yrange
LET maxy=curlocy+yrange
SET COLOR "BLACK/WHITE"
PRINT "zoomout",minx,maxx,miny,maxy
END SUB
SUB recenternozoom (minx,maxx,miny,maxy,curlocx,curlocy)
CALL flsw(minx,maxx,miny,maxy,xwidth,ywidth)
LET xrange=xwidth/2
LET yrange=ywidth/2
LET minx=curlocx-xrange
LET maxx=curlocx+xrange
LET miny=curlocy-yrange
LET maxy=curlocy+yrange
SET COLOR "BLACK/WHITE"
PRINT "recenter",minx,maxx,miny,maxy
END SUB

Comments

what am I missing...

Hi,

I tried to run what you posted but got these error messages:

! L120: illegal expression: DO while (4>a^2+b^2)and(itsvpix then
! l125: ending doesn't match beginning: END IF
! L126: Wrong type: IF hpixmaxits then

Maybe you meant LOOP in Line 125, but the others ?

Cheers
Mike C.