Circle selfmade
Verfasst: 27.03.2009 17:48
Aufgrund eines Posts im englischen Forum hab ich mich an einer Circle() Procedure versucht. Nun ist sie leicht langsamer als die von PB. auch erkennt man das PB einen etwas anderen Algo verwenden muss, hat jemand eine Idee?:
Code: Alles auswählen
Procedure _Circle(x0, y0, rad, color = 0)
Static x, y, rad2
rad2 = rad*rad
x = 0
y = 1
Plot(x0, y0 + rad, color)
Plot(x0, y0-rad, color)
Plot(x0 + rad, y0, color)
Plot(x0-rad, y0, color)
While x<y
x + 1
y = Sqr(rad2-x*x)
Plot(x0-x, y0-y, color)
Plot(x0-x, y0 + y, color)
Plot(x0 + x, y0-y, color)
Plot(x0 + x, y0 + y, color)
Plot(x0-y, y0-x, color)
Plot(x0-y, y0 + x, color)
Plot(x0 + y, y0-x, color)
Plot(x0 + y, y0 + x, color)
Wend
EndProcedure
OpenWindow(0, 0, 0, 450, 450, "demo", #PB_Window_SystemMenu)
#cnt = 100
If StartDrawing(WindowOutput(0))
t = ElapsedMilliseconds()
For i = 1 To #cnt
_Circle(120, 225, i, $ff)
Next
t1 = ElapsedMilliseconds()-t
DrawingMode(#PB_2DDrawing_Outlined)
DrawingMode(#PB_2DDrawing_Outlined)
t = ElapsedMilliseconds()
For i = 1 To #cnt
Circle(345, 225, i, $ff)
Next
t2 = ElapsedMilliseconds()-t
StopDrawing()
EndIf
MessageRequester("str", Str(t1) + Chr(13) + Str(t2))
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow