Mandelbrot- What am I doning wrong?

BlitzMax Forums/BlitzMax Programming/Mandelbrot- What am I doning wrong?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

@Indiepath.T
Yes, I think you'r right and yes I know. But what I do not know.

@Scott Shaver
Any ideas why that happens?

Here is the BB3D code
; Project: Mandelbrot - Speedtest
; Start: Tuesday, September 09, 2003
; Blitz3D - Linker Version 1.64


Global maxiter#=128 ; max iterations
SX# = -2.025 ; start value real
SY# = -1.125 ; start value imaginary
EX# = 0.6    ; End value real
EY# = 1.125  ; End value imaginary

x1# = 640    ; ScreenX
y1# = 480    ; ScreenY
xy# = x1# / y1#; x/y-ratio

   Graphics 640, 480, 16, 2
   xstart# = SX#
   ystart# = SY#
   xende# = EX#
   yende# = EY#

   xzoom# = (xende# - xstart#) / x1#
   yzoom# = (yende# - ystart#) / y1#
   fac#=0.999

  SetBuffer BackBuffer()
  While Not KeyDown(1)
      Cls
      xende# = xende#*fac#
      xstart#=xstart#*fac#
      ystart#=ystart#*fac#
      yende#=yende#*fac#
      xzoom# = (xende# - xstart#) / x1#
      yzoom# = (yende# - ystart#) / y1#
      mandelbrot(x1#, y1#, xstart#, ystart#, xzoom#, yzoom#)
      Locate 0,0
      thistime# = MilliSecs()
      Print "Speed: " + Str$(Int(x1#*y1# / (1+(thistime#-lasttime#)))) + " Kpix/sec"
      lasttime#=thistime#
      Flip
   Wend
End

; ------------------------------------------------------------- ;
; -=#  Mandelbrot  #=-
; ------------------------------------------------------------- ;
; calculate all points
Function mandelbrot(x1#, y1#, xstart#, ystart#, xzoom#, yzoom#)
; Local x, y, h, b, old, col
   LockBuffer BackBuffer()
   For x = 0 To x1#-1
      For y = 0 To y1#-1
         h# = DotsColor#(xstart# + xzoom# * x, ystart# + yzoom# * y) ; Color value
         If h# <> old#
            b# = 1.0 - h# * h# ; brightness
            col = HSBtoRGB(h#, 0.8, b#)
            old# = h#
         EndIf
         WritePixelFast x, y, col
      Next
   Next
   UnlockBuffer BackBuffer()
End Function


; ------------------------------------------------------------- ;
; -=#  DotsColor  #=-
; ------------------------------------------------------------- ;
; Color value from 0.0 To 1.0 by iterations
Function DotsColor#(xval#, yval#)
; Local r, i, j, m
   While (j# < maxiter#) And (m# < 4.0)
      j#=j#+1.0
      m# = r# * r# - i# * i#
      i# = 2.0 * r# * i# + yval#
      r# = m# + xval#
   Wend
   j# = j# / maxiter#
   Return j#
End Function

; ------------------------------------------------------------- ;
; -=#  RGB-Function - Come on, that's an important one...  #=-
; ------------------------------------------------------------- ;
Function RGB(red, green, blue)
   Return (red Shl 16) + (green Shl 8) + blue
End Function


; ------------------------------------------------------------- ;
; -=#  HSB2RGB  #=-
; ------------------------------------------------------------- ;
Function HSBtoRGB(hue#, saturation#, brightness#)
; Local red, green, blue, domainOffset // hue Mod 1/6

   If brightness# = 0 Then Return 0
   If saturation# = 0 Then Return RGB(Int(brightness#*255), Int(brightness#*255), Int(brightness#*255))

   ; Select not with <> allowed, have to use If here...
   If hue#  < 1.0/6.0
      ; red domain; green ascends
      domainOffset# = hue#
      red#   = brightness#
      blue#  = brightness# * (1.0 - saturation#)
      green# = blue# + (brightness# - blue#) * domainOffset# * 6
   Else
      If hue#  < 2.0/6.0
         ; yellow domain; red descends
         domainOffset# = hue# - 1.0/6.0
         green# = brightness#
         blue#  = brightness# * (1.0 - saturation#)
         red#   = green# - (brightness# - blue#) * domainOffset# * 6.0
      Else
         If hue#  < 3.0/6.0
            ; green domain; blue ascends
            domainOffset# = hue# - 2.0/6.0
            green# = brightness#
            red#   = brightness# * (1.0 - saturation#)
            blue#  = red# + (brightness# - red#) * domainOffset# * 6.0
         Else
            If hue#  < 4.0/6.0
               ; cyan domain; green descends
               domainOffset# = hue# - .5
               blue#  = brightness#
               red#   = brightness# * (1.0 - saturation#)
               green# = blue# - (brightness# - red#) * domainOffset# * 6.0
            Else
               If hue#  < 5.0/6.0
                  ; blue domain; red ascends
                  domainOffset# = hue# - 5.0/6.0
                  blue#  = brightness#
                  green# = brightness# * (1.0 - saturation#)
                  red#   = green# + (brightness# - green#) * domainOffset# * 6.0
               Else
                  ; magenta domain; blue descends
                  domainOffset# = hue# - 5.0/6.0
                  red#   = brightness#
                  green# = brightness# * (1.0 - saturation#)
                  blue#  = red# - (brightness# - green#) * domainOffset# * 6.0
               EndIf
            EndIf
         EndIf
      EndIf
   EndIf
   Return RGB(red# * 255.0, green# * 255.0, blue# * 255.0)
End Function


Sveinung