Fast & simple Mandelbrot

Blitz3D Forums/Blitz3D Programming/Fast & simple Mandelbrot

WritePixelFast are better solutions i guess :)
and if you put flip 0 on the END of the program, he doesnt flip 800x600 times the backbuffer ;)


Graphics 800,600,16,2
SetBuffer BackBuffer()
maxcolor=255
leftside#=-2 : top#=1.25
xside#=2.5 : yside#=-2.5
xmax=800 : ymax=600
xscale# = xside# / xmax
yscale# = yside# / ymax

AppTitle "please wait..."

LockBuffer
For y=0 To ymax - 1
	For x=0 To xmax - 1
		cx# = x * xscale# + leftside#
		cy# = y * yscale# + top#
		zx# = 0
		zy# = 0
		colorcounter = 0
		max = 5 ; 4
		While (zx# * zx# + zy# * zy# < max And colorcounter < maxcolor)
			tempx# = zx# * zx# - zy# * zy# + cx#
			zy# = 2 * zx# * zy# + cy#
			zx# = tempx#
			colorcounter=colorcounter+1
		Wend
		r = colorcounter * 8
		g = colorcounter * 4
		b = colorcounter * 1
		WritePixelFast x, y, r*$10000 + g*$100 + b, GraphicsBuffer()
	Next
Next
UnlockBuffer
Flip

WaitKey
End


cu