
Code : Tout sélectionner
; Based on book : Algorithmes et structures de données by Michel Divay (C programming)
; Coded and adapted by threedslider 08.07.2022
Procedure Cercle(X.i, Y.i, R.i)
For n=0 To 1800
cx = R * Cos(n)
cy= R * Sin(n)
Plot(cx+X,cy+Y,RGB(255,0,0))
Next
EndProcedure
Procedure DeuxCercles(X.i, Y.i, R.i)
_r.i = 0
If R > 10
cercle(X, Y, R)
_r = R / 2
DeuxCercles(X+_r, Y, _r)
DeuxCercles(X-_r, Y, _r)
EndIf
EndProcedure
If OpenWindow(0, 0, 0, 600, 600, "Two circles in recursive", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If CreateImage(0, 600, 600) And StartDrawing(ImageOutput(0))
DeuxCercles(300,300,200)
StopDrawing()
ImageGadget(0, 0, 0, 200, 200, ImageID(0))
EndIf
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf