Image noise: Difference between revisions
Content added Content deleted
m (→{{header|PureBasic}}: Update to 320x240 and showing output) |
m (→{{header|PureBasic}}: Increased FPS by running without synchronization) |
||
Line 248: | Line 248: | ||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |
||
<lang PureBasic>#filter=0. |
<lang PureBasic>#filter=0.2 ; Filter parameter for the FPS-calculation |
||
#UpdateFreq=100 ; How often to update the FPS-display |
|||
#Flags =#PB_Window_SystemMenu|#PB_Window_SizeGadget|#PB_Window_MinimizeGadget |
|||
OpenWindow(0,400,300,320,240,"PureBasic") |
|||
⚫ | |||
SmartWindowRefresh(0,#True) |
|||
⚫ | |||
AddWindowTimer(0,0,1) |
|||
InitSprite() |
|||
⚫ | |||
OpenWindowedScreen(WindowID(0),0,0,w,h,1,0,0,#PB_Screen_NoSynchronization) |
|||
⚫ | |||
Repeat |
|||
Define Event=WaitWindowEvent() |
|||
⚫ | |||
Select Event |
|||
StartDrawing(ScreenOutput()) |
|||
Case #PB_Event_Timer |
|||
For y=0 To h-1 |
|||
⚫ | |||
For x=0 To w-1 |
|||
If Random(1) |
|||
Plot(x,y,#Black) |
|||
Else |
|||
Plot(x,y,#White) |
|||
⚫ | |||
Plot(x,y,#White) |
|||
Next |
|||
Next |
|||
⚫ | |||
Next |
|||
FlipBuffers() |
|||
⚫ | |||
cnt+1 |
|||
⚫ | |||
If cnt>=#UpdateFreq |
|||
dT=(T-TOld) |
|||
⚫ | |||
If dT |
|||
FloatingMedium*(1-#filter)+1000*#filter/(T-TOld) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
If Not cnt%10 |
|||
Event=WindowEvent() |
|||
⚫ | |||
⚫ | |||
⚫ | |||
End |
|||
⚫ | |||
ImageGadget(0,0,0,w,h,ImageID(0)) |
|||
Until Not Event |
|||
EndIf |
|||
⚫ | |||
ForEver</lang> |
|||
[[Image:Image_Noise_in_PureBasic.png]] |
[[Image:Image_Noise_in_PureBasic.png]] |
||