Mandelbrot set: Difference between revisions
Content deleted Content added
Line 843: | Line 843: | ||
<lang PureBasic>EnableExplicit |
<lang PureBasic>EnableExplicit |
||
#Window1 = 0 |
|||
⚫ | |||
#Image1 = 0 |
|||
#ImgGadget = 0 |
|||
⚫ | |||
#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( |
If OpenWindow(#Window1, 0, 0, #width, #height, "'Mandelbrot set' PureBasic Example", #PB_Window_SystemMenu ) |
||
If CreateImage( |
If CreateImage(#Image1, #width, #height) |
||
ImageGadget(#ImgGadget, 0, 0, #width, #height, ImageID(#Image1)) |
|||
For y.i = 1 To #height -1 |
|||
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, |
Plot(x, y, 0 ) |
||
Else |
|||
Plot(x, y, Color(i & 255)) |
|||
EndIf |
|||
Next |
Next |
||
⚫ | |||
SetGadgetState(#ImgGadget, ImageID(#Image1)) |
|||
Repeat |
|||
Event = WindowEvent() |
|||
If Event = #PB_Event_CloseWindow |
|||
End |
|||
EndIf |
|||
Until Event = 0 |
|||
Next |
Next |
||
⚫ | |||
ImageGadget(0, 0, 0, 200, 200, ImageID(0)) |
|||
EndIf |
EndIf |
||
Repeat |
Repeat |
||
Event = WaitWindowEvent() |
Event = WaitWindowEvent() |