Mandelbrot set: Difference between revisions

Content deleted Content added
Christian (talk | contribs)
Christian (talk | contribs)
Line 843: Line 843:
<lang PureBasic>EnableExplicit
<lang PureBasic>EnableExplicit


#Window1 = 0
#max_iteration = 255
#Image1 = 0
#ImgGadget = 0

#max_iteration = 64
#width = 800
#width = 800
#height = 600
#height = 600
Define.d x0 ,y0 ,xtemp ,cr, ci
Define.d x0 ,y0 ,xtemp ,cr, ci
Define.i i, x, y ,Event ,color
Define.i i, n, x, y ,Event ,color

Dim Color.l (255)
For n = 0 To 63
Color( 0 + n ) = RGB( n*4+128, 4 * n, 0 )
Color( 64 + n ) = RGB( 64, 255, 4 * n )
Color( 128 + n ) = RGB( 64, 255 - 4 * n , 255 )
Color( 192 + n ) = RGB( 64, 0, 255 - 4 * n )
Next


If OpenWindow(0, 0, 0, #width, #height, "'Mandelbrot set' PureBasic Example", #PB_Window_SystemMenu )
If OpenWindow(#Window1, 0, 0, #width, #height, "'Mandelbrot set' PureBasic Example", #PB_Window_SystemMenu )
If CreateImage(0, #width, #height) And StartDrawing(ImageOutput(0))
If CreateImage(#Image1, #width, #height)
For x.i = 1 To #width -1
ImageGadget(#ImgGadget, 0, 0, #width, #height, ImageID(#Image1))
For y.i = 1 To #height -1
For y.i = 1 To #height -1
x0 = 0
StartDrawing(ImageOutput(#Image1))
For x.i = 1 To #width -1
x0 = 0
y0 = 0;
y0 = 0;
cr = (x / #width)*2.5 -2
cr = (x / #width)*2.5 -2
Line 864: Line 878:
x0 = xtemp
x0 = xtemp
Wend
Wend
If i >= #max_iteration
color = i*150+5000 ;RGB( Abs(i-200) ,Abs(i-127) , Abs(i-80)) ;(255/i)*5000 ;
Plot(x, y, color)
Plot(x, y, 0 )
Else
Plot(x, y, Color(i & 255))
EndIf
Next
Next
StopDrawing()
SetGadgetState(#ImgGadget, ImageID(#Image1))
Repeat
Event = WindowEvent()
If Event = #PB_Event_CloseWindow
End
EndIf
Until Event = 0
Next
Next
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
EndIf
Repeat
Repeat
Event = WaitWindowEvent()
Event = WaitWindowEvent()