Re: Kreis Punkte setzen
Verfasst: 06.02.2008 12:15
na dann halt so :
EDIT: da kann man ja richtig geile Sachen draus zauber 
Code: Alles auswählen
Global teiler.l,Image0
teiler=360/12
Enumeration
#Window_0
EndEnumeration
Enumeration
#Image_0
EndEnumeration
Image0 = CreateImage(0,500,500)
StartDrawing(ImageOutput(0))
Box(0,0,500,500,RGB(255,255,255))
StopDrawing()
; Berechnet den Winkel
Procedure.f Winkel(x.f,y.f)
Winkel.f
If x = 0
If y < 0 : Winkel = -90 : EndIf
If y >= 0 : Winkel = 90 : EndIf
Else
Winkel = ATan(y/x)/#PI*180
If x < 0 : Winkel + 180 : EndIf
EndIf
ProcedureReturn Winkel
EndProcedure
Procedure.f Abstand(x1, y1, x2, y2)
r.f = Sqr(Pow(x1-x2,2)+Pow(y1-y2,2))
ProcedureReturn r
EndProcedure
Procedure GetMouseX(Gadget)
GetCursorPos_(mouse.POINT)
MapWindowPoints_(0,GadgetID(Gadget),mouse,1)
ProcedureReturn mouse\x
EndProcedure
Procedure GetMouseY(Gadget)
GetCursorPos_(mouse.POINT)
MapWindowPoints_(0,GadgetID(Gadget),mouse,1)
ProcedureReturn mouse\y
EndProcedure
Procedure Open_Window_0()
If OpenWindow(#Window_0, 391, 283, 521, 511, "test", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_0, 10, 10, 500, 500, Image0)
EndIf
EndIf
EndProcedure
Open_Window_0()
Repeat
Event = WaitWindowEvent()
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
If GetAsyncKeyState_(#VK_LBUTTON)
winkel=0
posx= GetMouseX(#Image_0)
posy=GetMouseY(#Image_0)
x_mitte=250
y_mitte=250
Start.f = Winkel(posx-x_mitte,posy-y_mitte)
Radius.f = Abstand(posx,posy,x_mitte,y_mitte)
If posx>0 And posx<501
If posy>0 And posy<501
For n = 0 To 330 Step 30
winkel = Start+n
x = Radius * Cos(winkel *(2*3.1415/360)) + x_mitte ; Winkel als Bogenmaß
y = Radius * Sin(winkel *(2*3.1415/360)) + y_mitte
StartDrawing(ImageOutput(0))
Box(posx,posy,4,4,RGB(0,0,0))
Box(x,y,4,4,RGB(0,0,0))
StopDrawing()
SetGadgetState(#Image_0,ImageID(0))
Next
EndIf
EndIf
EndIf
If Event = #PB_Event_Gadget
EndIf
Until Event = #PB_Event_CloseWindow
End
