Das hat nicht viel mit GDI+ zu tun, sondern eher was mit Mathe! ![]()
Spoiler anzeigen
#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
Opt("GUIOnEventMode", 1)
Global $hWnd, $hGraphic, $hPen, $x1, $x2, $y1, $y2, $grad, $clock
Global $iX = 400, $iY = 400, $rI = 30, $rO = 180, $i = 180
Global $Pi = 4 * ATan(1), $Pi_Div_180 = $Pi / 180, $w_mid = $iX / 2, $h_mid = $iY / 2
; Erstellt eine GUI
$hWnd = GUICreate("GDI+", $iX, $iY)
GUISetState()
_GDIPlus_Startup() ;initialisiere GDI+
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd) ;erstelle Grafik Objekt in Verbindug mit der GUI
_GDIPlus_GraphicsSetSmoothingMode($hGraphic, 4) ;aktiviere Kantenglättung
_GDIPlus_GraphicsClear($hGraphic, 0xFF000000) ;lösche Grafik
$hPen = _GDIPlus_PenCreate(0xFFFF0000, 4) ;erstelle Stift mit 4 Pixel Breite
$Ellipse = _GDIPlus_GraphicsDrawEllipse($hGraphic, $iX / 2 - 10, $iY / 2 - 10, 20, 20, $hPen) ;zeichne Kreis in der Mitte
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;Aktiviere Exit wenn $GUI_EVENT_CLOSE ausgelöst wird
[/autoit] [autoit][/autoit] [autoit]Do
$grad = Mod(180 - $i, 360) ;berechne Winkel (0 - 359)
$clock = Floor($grad / 30) ;berechne Uhrzeit (0-11)
WinSetTitle($hWnd, "", "GDI+ Demo by UEZ -=> " & $grad & "° / " & $clock) ;schreibe Infos in die Windows Titelleiste
$x1 = $rI * Sin($i * $Pi_Div_180) + $w_mid ;berechne Punkt x1 vom inneren Kreis
$y1 = $rI * Cos($i * $Pi_Div_180) + $h_mid ;berechne Punkt y1 vom inneren Kreis
$x2 = $rO * Sin($i * $Pi_Div_180) + $w_mid ;berechne Punkt x2 vom äußeren Kreis
$y2 = $rO * Cos($i * $Pi_Div_180) + $h_mid ;berechne Punkt y2 vom äußeren Kreis
_GDIPlus_PenSetColor($hPen, "0xF0" & Hex(Random(0x111111, 0xFFFFFF, 1), 6)) ;kreiere neue Stiftfarbe zufällig
_GDIPlus_GraphicsDrawLine($hGraphic, $x1, $y1, $x2, $y2, $hPen) ;zeichne Linie
$i -= 1
Until Not Sleep(20)
Func _Exit()
; Ressourcen freigeben
_GDIPlus_PenDispose($hPen)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc
Gruß,
UEZ