Ja ich hatte vor einiger Zeit einmal Langeweile, und dachte mir, dass ich mal wieder was mit GDI+ mach.
Da mir aber die Berechnungen mit den Winkelfunktionen zu umständlich sind, hab ich mich mal an Matrizen versucht.
Und tada, hier ist:
Spoiler anzeigen
#include <WinAPI.au3>
#include <GDIPlus.au3>
#include <Misc.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $hWnd, $hGraphic, $hBitmap, $backbuffer[4], $hFormat, $hFamily, $hFont, $tLayout, $aInfo, $matrix[3]
Global $pen[1]
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
Global $title = "GDI+ Beispiel: Matrizen", _
$width = 700, _
$height = 700
Global $Colour = 0x00FF0000, _
$Count = 3
$CountR = 1
$hWnd = GUICreate($title, $width, $height, -1, -1, 0x80000000, BitOR(0x00000080, 0x00080000, 0x00000008))
GUISetOnEvent(-3, "_Close")
GUISetState()
_Win_SetClickThrough($hWnd, True)
[/autoit] [autoit][/autoit] [autoit]_Startup()
[/autoit] [autoit][/autoit] [autoit]AdlibRegister("_Draw", 10)
AdlibRegister("_Key", 10)
While 1
Sleep(100)
WEnd
Func _Draw()
If $Count = 1 Then
$Colour -= 0x01000100
_GDIPlus_PenSetColor($pen[0], $Colour)
If Hex($Colour) = Hex(0x00FF0000) Then $Count = 2
ElseIf $Count < 3 And $Count >= 2 Then
$Count += 0.01
ElseIf $Count >= 3 Then
$Colour += 0x01000100
_GDIPlus_PenSetColor($pen[0], $Colour)
If Hex($Colour) = Hex(0xFFFFFF00) Then $Count = 1
EndIf
_GDIPlus_GraphicsClear($backbuffer[2], 0x00000000)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_MatrixRotate($matrix[0], $CountR)
_GDIPlus_GraphicsSetTransform($backbuffer[0], $matrix[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], 0, -100, 0, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], -100, 0, 100, 0, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[0], -100, -100, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[0], -50, -50, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[0], -250, 50, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[0], 100, 100, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], 150, 50, 150, 250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], 50, 150, 250, 150, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[0], 50, 50, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[0], -200, 100, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], -150, 50, -150, 250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], -50, 150, -250, 150, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[0], 50, -250, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[0], -200, -200, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], -150, -50, -150, -250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], -50, -150, -250, -150, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[0], -250, -250, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[0], 100, -200, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], 150, -50, 150, -250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[0], 50, -150, 250, -150, $pen[0])
_GDIPlus_MatrixRotate($matrix[1], -$CountR)
_GDIPlus_GraphicsSetTransform($backbuffer[1], $matrix[1])
_GDIPlus_GraphicsDrawRect($backbuffer[1], -50, -50, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], 0, -100, 0, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], -100, 0, 100, 0, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[1], -250, 50, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[1], 100, 100, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], 150, 50, 150, 250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], 50, 150, 250, 150, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[1], 50, 50, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[1], -200, 100, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], -150, 50, -150, 250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], -50, 150, -250, 150, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[1], 50, -250, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[1], -200, -200, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], -150, -50, -150, -250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], -50, -150, -250, -150, $pen[0])
_GDIPlus_GraphicsDrawEllipse($backbuffer[1], -250, -250, 200, 200, $pen[0])
_GDIPlus_GraphicsDrawRect($backbuffer[1], 100, -200, 100, 100, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], 150, -50, 150, -250, $pen[0])
_GDIPlus_GraphicsDrawLine($backbuffer[1], 50, -150, 250, -150, $pen[0])
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_WinAPI_SelectObject($dc, $gdibitmap)
_WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
EndFunc
Func _Key()
If _IsPressed("6B") Then $CountR += 0.01
If _IsPressed("6D") Then $CountR -= 0.01
EndFunc
Func _Startup()
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
For $i = 0 To 2
$matrix[$i] = _GDIPlus_MatrixCreate()
_GDIPlus_MatrixTranslate($matrix[$i], $width/2, $height/2)
_GDIPlus_MatrixRotate($matrix[$i], 0)
_GDIPlus_GraphicsSetTransform($backbuffer[$i], $matrix[$i])
$backbuffer[$i] = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer[$i], 4)
Next
$pen[0] = _GDIPlus_PenCreate($Colour, 10)
[/autoit] [autoit][/autoit] [autoit]$ScreenDc = _WinAPI_GetDC($hWnd)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $width)
DllStructSetData($tSize, "Y", $height)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 255)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 9, 0, 2)
$tLayout = _GDIPlus_RectFCreate(20, 25, 110, 155)
EndFunc
Func _Close()
For $i = 0 To 2
_GDIPlus_GraphicsDispose($backbuffer[$i])
_GDIPlus_MatrixDispose($matrix[$i])
Next
_WinAPI_ReleaseDC($hWnd, $ScreenDc)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc
Func _Win_SetClickThrough($hGUI, $noclic = True)
Local $hWnd = WinGetHandle(WinGetTitle($hGUI), "")
If @error Then Return SetError(1,0,0)
If $noclic Then
_WinAPI_SetWindowLong($hWnd,0xFFFFFFEC,BitOR(_WinAPI_GetWindowLong($hWnd,0xFFFFFFEC),0x00000020))
If @error Then Return SetError(2,0,0)
Else
_WinAPI_SetWindowLong($hWnd,0xFFFFFFEC,BitAND(_WinAPI_GetWindowLong($hWnd,0xFFFFFFEC),BitNOT(0x00000020)))
If @error Then Return SetError(2,0,0)
EndIf
Return 1
EndFunc
Ist zwar nichts besonderes, aber ich habs trotzdem mal reingestellt.
Mit den Tasten Numpad + / - könnt ihr die Geschwindigkeit erhöhen, bzw. senken.