Hey Community
ich habe nochmal eine kleine Frage zu GDI+. Und zwar hatte ich vor, ein Element (_GDIPlus_GraphicsFillRect)
in einer Schleife z.B 10x zu klonen, ohne das ich jetzt 10x _GDIPlus_GraphicsFillRect dahin schreiben muss.
Bei meinem Script soll die Schleife 10x einen roten Punkt erstellen, der dann jeweils eine zufällige Position einnimmt.
Mit "_GDIPlus_BitmapCloneArea" habe ich das schon versucht, aber leider kommt trotzdem nur ein einziger Punkt zurzeit.
AutoIt
#include <GuiConstants.au3>
#include <GdiPlus.au3>;das include
#include <Misc.au3>
OnAutoItExitRegister("_end") ; die Funktion _end am Ende des Scriptes ausführen
Global $GUI_Width = 100
Global $GUI_Height = 100
_GDIPlus_Startup()
$Gui = GUICreate("", $GUI_Width, $GUI_Height, -1, -1, $WS_POPUP, $WS_EX_CONTROLPARENT)
$graphic = _GDIPlus_GraphicsCreateFromHWND($Gui);Frontbuffer
$bitmap = _GDIPlus_BitmapCreateFromGraphics(100, 100, $graphic)
$buffer = _GDIPlus_ImageGetGraphicsContext($bitmap);Backbuffer
; GDI Declaration
$gdiBg = _GDIPlus_BrushCreateSolid(0xFFEE88BB)
_GDIPlus_GraphicsFillRect($graphic, 0, 0, 100, 100, $gdiBg)
$gdiObj = _GDIPlus_BrushCreateSolid(0xFFEE2C2C)
_GDIPlus_GraphicsFillRect($graphic, 10, 5, 8, 8, $gdiObj)
GUISetState(@SW_SHOW)
Do
_Draw()
Until GUIGetMsg() = $GUI_EVENT_CLOSE
Func _end();die Exit funktion
_GDIPlus_GraphicsDispose($graphic);Grafik Objekt freigeben
_GDIPlus_GraphicsDispose($buffer)
_GDIPlus_BitmapDispose($bitmap)
_GDIPlus_Shutdown();Ressourcen freigeben
EndFunc
Func _Draw()
$resultX = Random(10, 30, 1)
$resultY = Random(10, 30, 1)
_GDIPlus_GraphicsClear($buffer);Inhalt des Backbuffer`s wird gelöscht
_GDIPlus_GraphicsFillRect($buffer, 0, 0, 100, 100, $gdiBg)
$ddd = _GDIPlus_GraphicsFillRect($buffer, 30 - $resultX, 30+ $resultY, 8, 8, $gdiObj)
For $i = 1 To 10
$resultX = Random(10, 30, 1)
$resultY = Random(10, 30, 1)
_GDIPlus_BitmapCloneArea($ddd, 30 - $resultX, 30 + $resultY, 8, 8, $gdiObj)
Next
_GDIPlus_GraphicsDrawImage($graphic, $bitmap, 0, 0) ;Backbuffer wird an den Frontbuffer übergeben
Sleep(500)
EndFunc
Alles anzeigen
Kann mir jemand helfen?