Image noise: Difference between revisions

m
→‎{{header|PureBasic}}: Increased FPS by running without synchronization
m (→‎{{header|PureBasic}}: Update to 320x240 and showing output)
m (→‎{{header|PureBasic}}: Increased FPS by running without synchronization)
Line 248:
 
=={{header|PureBasic}}==
<lang PureBasic>#filter=0.022 ; 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
 
If OpenWindow(0,#PB_Ignore400,#PB_Ignore300,320,240,"PureBasic",#Flags)
Define w=WindowWidth(0), h=WindowHeight(0)
SmartWindowRefresh(0,#True)
Define x, y, dT, T, TOld, FloatingMedium.f, cnt
AddWindowTimer(0,0,1)
InitSprite()
Repeat
OpenWindowedScreen(WindowID(0),0,0,w,h,1,0,0,#PB_Screen_NoSynchronization)
Define x, y, dT, T, TOld, FloatingMedium.f, cnt
Repeat
Define Event=WaitWindowEvent()
cnt+1
Select Event
StartDrawing(ScreenOutput())
Case #PB_Event_Timer
For y=0 To h-1
Define w=WindowWidth(0), h=WindowHeight(0)
For x=0 To CreateImage(0,w+1,h+-1)
If StartDrawing(ImageOutputRandom(0)1)
For Plot(x,y=0 To h,#Black)
For x=0 To wElse
If RandomPlot(1x,y,#White)
EndIf
Plot(x,y,#White)
EndIfNext
Next
StopDrawing()
Next
FlipBuffers()
StopDrawing()
cnt+1
TOld=T: T=ElapsedMilliseconds()
If cnt>=#UpdateFreq
dT=(T-TOld)
cnt=0: TOld=T: T=ElapsedMilliseconds()
If dT
FloatingMedium*(1-#filter)+1000*#filter/dT(T-TOld)
SetWindowTitle(0,"PureBasic: "+StrF(#UpdateFreq*FloatingMedium,2)+" fps.FPS")
cnt+1
Repeat
If Not cnt%10
Event=WindowEvent()
SetWindowTitle(0,"PureBasic: "+StrF(FloatingMedium,2)+" fps.")
Until If Event=#PB_Event_CloseWindow
EndIf
EndIfEnd
NextEndIf
ImageGadget(0,0,0,w,h,ImageID(0))
EndSelectUntil Not Event
EndIf
Until Event=#PB_Event_CloseWindow
EndIfForEver</lang>
[[Image:Image_Noise_in_PureBasic.png‎]]
 
Anonymous user