D'avance merci pour votre aide.
Code : Tout sélectionner
EnableExplicit
Enumeration window
#mf
EndEnumeration
Enumeration gadget
#mfResult
#mfModulo
#mfView
EndEnumeration
; Font d'affichage des nombres
Global Font = LoadFont(#PB_Any, "", 10)
; Sommaire
Declare Start()
Declare ViewResult()
Declare Exit()
Start()
Procedure Start()
OpenWindow(#mf, 0, 0, 1024, 768, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
; Affichage du résultat
CanvasGadget(#mfResult, 0, 0, 1024, 700)
TextGadget(#PB_Any, 10, 710, 100, 24, "Nombre de points")
StringGadget(#mfModulo, 120, 710, 50, 24, "10", #PB_String_Numeric | #PB_String_InPlace)
ButtonGadget(#mfView, 930, 710, 80, 24, "View")
SetActiveGadget(#mfModulo)
ViewResult()
; Déclencheur
BindGadgetEvent(#mfView, @ViewResult())
BindEvent(#PB_Event_CloseWindow, @Exit())
Repeat : WaitWindowEvent(10) : ForEver
EndProcedure
Procedure ViewResult()
; Centre du cercle & Rayon
Protected XC = GadgetWidth(#mfResult)/2
Protected YC = GadgetHeight(#mfResult)/2
Protected Radius, X, Y, N.f, I
; Nombre de points sur le cercle
Protected Modulo = Val(GetGadgetText(#mfModulo))
If Modulo < 1
MessageRequester("Information", "Le nombre de points doit être supérieur à 0")
SetGadgetText(#mfModulo, "1")
Modulo = 1
EndIf
If StartDrawing(CanvasOutput(#mfResult))
; Clear Canvas
Box(0, 0, 1024, 700, RGB(255, 255, 255))
While N < 360
Radius = 250
; Affichage du point
X = XC + Radius * Cos(N * #PI / 180)
Y = YC + Radius * Sin(N * #PI / 180)
Circle(X, Y, 2, RGB(255, 69, 0))
; Affichage de la valeur du point
Radius = 300
X = XC + Radius * Cos(N * #PI / 180)
Y = YC + Radius * Sin(N * #PI / 180)
DrawingFont(FontID(Font))
DrawingMode(#PB_2DDrawing_Transparent)
DrawText(X, Y, Str(I), RGB(0, 0, 255))
; Point suivant
N + 360/Modulo
I + 1
Wend
StopDrawing()
EndIf
EndProcedure
Procedure Exit()
End
EndProcedure