Kreisförmig anordnen
Kreisförmig anordnen
Ich möchte eine bestimmte anzahl von bilder kreisförmig anordenen mit angabe in welchem radius das passieren soll und angabe der anzahl der bilder wie mache ich das am besten?
Purebasic 5.0 32bit und 64 bit
I'm back from hell
I'm back from hell
- Du setzt den Mittelpunkt deines Kreises
-
For a=1 to Bilder
BildMittelpunktx=Kreismittelpunktx+cos(2*#PI/Bilder*a)*Radius
BildMittelpunkty=Kreismittelpunkty+sin(2*#PI/Bilder*a)*Radius
next - Du errechnest aus dem Mittelpunkt für jedes Bild die Koordinaten der linken oberen Ecke
- Du zeigst das ganze an
Weitere Fragen beantworte ich dir gerne
edit: Beispielcode
Code: Alles auswählen
;- Code by Macros
;- Order images on a circle
OpenWindow(1,0,0,600,600,"Kreistest",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
CreateGadgetList(WindowID(1))
ImageGadget(1,0,0,600,600,0)
CreateImage(0,600,600)
Bilder=10
For a=1 To Bilder
width=Random(80)+40
height=Random(80)+40
CreateImage(a,width,height)
StartDrawing(ImageOutput(a))
Box(0,0,width,height,RGB(Random(255),Random(255),Random(255)))
Box(2,2,width-4,height-4,RGB(Random(255),Random(255),Random(255)))
StopDrawing()
Next
Repeat
kreislauf.f+0.01
;-Schritt 1
mittelpunktx=300
mittelpunkty=300
Radius=200
StartDrawing(ImageOutput(0))
Box(0,0,600,600,0) ; Hintergrund löschen
For a=1 To Bilder
;-Schritt 2
; BildMittelpunktx=mittelpunktx+Cos(2*#PI/Bilder*a)*Radius
; BildMittelpunkty=mittelpunkty+Sin(2*#PI/Bilder*a)*Radius
;-Schritt 2 mit Umlauf
BildMittelpunktx=mittelpunktx+Cos(2*#PI/Bilder*a+kreislauf)*Radius
BildMittelpunkty=mittelpunkty+Sin(2*#PI/Bilder*a+kreislauf)*Radius
;- Schritt 3
Bildx=BildMittelpunktx-ImageWidth(a)/2
Bildy=BildMittelpunkty-ImageHeight(a)/2
;- Schritt 4
DrawImage(ImageID(a),Bildx,Bildy)
;- Nur zur Verdeutlichung (grüne Ankerkreise)
Circle(BildMittelpunktx,BildMittelpunkty,5,$ff00)
Next
;- wie auch das hier (der Kreis auf dem die Bilder liegen)
DrawingMode(#PB_2DDrawing_Outlined)
Circle(mittelpunktx,mittelpunkty,Radius,$ff)
StopDrawing()
SetGadgetState(1,ImageID(0))
Delay(10)
Until WindowEvent()=#PB_Event_CloseWindow
Zuletzt geändert von Macros am 05.01.2008 14:01, insgesamt 1-mal geändert.
